| Filename | /usr/libdata/perl5/Exporter.pm |
| Statements | Executed 787 statements in 11.2ms |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 50 | 50 | 26 | 10.1ms | 13.9ms | Exporter::import |
| 10 | 2 | 1 | 1.64ms | 1.76ms | Exporter::as_heavy |
| 355 | 2 | 1 | 348µs | 348µs | Exporter::CORE:match (opcode) |
| 294 | 2 | 1 | 239µs | 239µs | Exporter::CORE:subst (opcode) |
| 8 | 1 | 1 | 66µs | 1.79ms | Exporter::export |
| 2 | 2 | 2 | 18µs | 58µs | Exporter::export_ok_tags |
| 0 | 0 | 0 | 0s | 0s | Exporter::__ANON__[:64] |
| 0 | 0 | 0 | 0s | 0s | Exporter::export_fail |
| 0 | 0 | 0 | 0s | 0s | Exporter::export_tags |
| 0 | 0 | 0 | 0s | 0s | Exporter::export_to_level |
| 0 | 0 | 0 | 0s | 0s | Exporter::require_version |
| Line | State ments |
Time on line |
Calls | Time in subs |
Code |
|---|---|---|---|---|---|
| 1 | package Exporter; | ||||
| 2 | |||||
| 3 | 1 | 21µs | require 5.006; | ||
| 4 | |||||
| 5 | # Be lean. | ||||
| 6 | #use strict; | ||||
| 7 | #no strict 'refs'; | ||||
| 8 | |||||
| 9 | 1 | 1µs | our $Debug = 0; | ||
| 10 | 1 | 800ns | our $ExportLevel = 0; | ||
| 11 | 1 | 900ns | our $Verbose ||= 0; | ||
| 12 | 1 | 2µs | our $VERSION = '5.72'; | ||
| 13 | our (%Cache); | ||||
| 14 | |||||
| 15 | sub as_heavy { | ||||
| 16 | 10 | 113µs | require Exporter::Heavy; | ||
| 17 | # Unfortunately, this does not work if the caller is aliased as *name = \&foo | ||||
| 18 | # Thus the need to create a lot of identical subroutines | ||||
| 19 | 10 | 58µs | my $c = (caller(1))[3]; | ||
| 20 | 10 | 81µs | 10 | 44µs | $c =~ s/.*:://; # spent 44µs making 10 calls to Exporter::CORE:subst, avg 4µs/call |
| 21 | 10 | 66µs | \&{"Exporter::Heavy::heavy_$c"}; | ||
| 22 | } | ||||
| 23 | |||||
| 24 | # spent 1.79ms (66µs+1.72) within Exporter::export which was called 8 times, avg 223µs/call:
# 8 times (66µs+1.72ms) by Exporter::import at line 62, avg 223µs/call | ||||
| 25 | 8 | 104µs | 16 | 3.12ms | goto &{as_heavy()}; # spent 1.72ms making 8 calls to Exporter::as_heavy, avg 215µs/call
# spent 1.40ms making 8 calls to Exporter::Heavy::heavy_export, avg 175µs/call |
| 26 | } | ||||
| 27 | |||||
| 28 | # spent 13.9ms (10.1+3.73) within Exporter::import which was called 50 times, avg 277µs/call:
# once (5.13ms+282µs) by IO::Uncompress::Gunzip::BEGIN@16 at line 16 of IO/Uncompress/Gunzip.pm
# once (401µs+1.80ms) by OpenBSD::PackageInfo::BEGIN@39 at line 39 of OpenBSD/PackageInfo.pm
# once (148µs+605µs) by File::Glob::import at line 46 of File/Glob.pm
# once (495µs+44µs) by IO::Uncompress::RawInflate::BEGIN@8 at line 8 of IO/Uncompress/RawInflate.pm
# once (423µs+24µs) by IO::Compress::Base::Common::BEGIN@8 at line 8 of IO/Compress/Base/Common.pm
# once (368µs+28µs) by Compress::Raw::Zlib::BEGIN@6 at line 6 of Compress/Raw/Zlib.pm
# once (79µs+231µs) by IO::Compress::Zlib::Extra::BEGIN@13 at line 13 of IO/Compress/Zlib/Extra.pm
# once (105µs+156µs) by IO::Uncompress::RawInflate::BEGIN@9 at line 9 of IO/Uncompress/RawInflate.pm
# once (214µs+17µs) by OpenBSD::PackageRepository::Installed::BEGIN@197 at line 198 of OpenBSD/PackageRepository/Installed.pm
# once (185µs+26µs) by IO::Uncompress::Base::BEGIN@17 at line 17 of IO/Uncompress/Base.pm
# once (180µs+20µs) by IO::Uncompress::Base::BEGIN@19 at line 147 of IO/File.pm
# once (165µs+21µs) by IO::Uncompress::Base::BEGIN@19 at line 19 of IO/Uncompress/Base.pm
# once (155µs+30µs) by IO::Uncompress::Adapter::Inflate::BEGIN@8 at line 8 of IO/Uncompress/Adapter/Inflate.pm
# once (159µs+8µs) by OpenBSD::State::BEGIN@86 at line 86 of OpenBSD/State.pm
# once (26µs+127µs) by IO::Uncompress::Adapter::Inflate::BEGIN@7 at line 7 of IO/Uncompress/Adapter/Inflate.pm
# once (23µs+110µs) by IO::Uncompress::Gunzip::BEGIN@15 at line 15 of IO/Uncompress/Gunzip.pm
# once (116µs+12µs) by OpenBSD::PkgInfo::BEGIN@177 at line 177 of OpenBSD/PkgInfo.pm
# once (116µs+12µs) by OpenBSD::PackageLocation::BEGIN@23 at line 23 of OpenBSD/PackageLocation.pm
# once (116µs+9µs) by OpenBSD::State::BEGIN@88 at line 88 of OpenBSD/State.pm
# once (112µs+12µs) by OpenBSD::PkgInfo::State::BEGIN@65 at line 65 of OpenBSD/PkgInfo.pm
# once (87µs+6µs) by OpenBSD::Error::BEGIN@72 at line 72 of OpenBSD/Error.pm
# once (24µs+65µs) by OpenBSD::Getopt::getopts at line 85 of OpenBSD/Getopt.pm
# once (84µs+5µs) by IO::Compress::Base::Common::BEGIN@7 at line 7 of IO/Compress/Base/Common.pm
# once (79µs+4µs) by File::GlobMapper::BEGIN@5 at line 5 of File/GlobMapper.pm
# once (63µs+8µs) by File::Path::BEGIN@6 at line 6 of File/Path.pm
# once (64µs+5µs) by OpenBSD::PackageRepository::Local::BEGIN@454 at line 454 of OpenBSD/PackageRepository.pm
# once (61µs+5µs) by OpenBSD::PackageRepository::BEGIN@32 at line 32 of OpenBSD/PackageRepository.pm
# once (60µs+5µs) by OpenBSD::PackageLocation::BEGIN@25 at line 25 of OpenBSD/PackageLocation.pm
# once (60µs+4µs) by IO::Compress::Base::Common::BEGIN@523 at line 523 of IO/Compress/Base/Common.pm
# once (57µs+5µs) by OpenBSD::Temp::BEGIN@25 at line 25 of OpenBSD/Temp.pm
# once (55µs+5µs) by OpenBSD::PkgInfo::BEGIN@180 at line 180 of OpenBSD/PkgInfo.pm
# once (56µs+3µs) by IO::File::BEGIN@130 at line 130 of IO/File.pm
# once (51µs+4µs) by IO::File::BEGIN@131 at line 131 of IO/File.pm
# once (49µs+3µs) by IO::Seekable::BEGIN@104 at line 104 of IO/Seekable.pm
# once (43µs+7µs) by IO::Handle::BEGIN@266 at line 266 of IO/Handle.pm
# once (45µs+3µs) by IO::Handle::BEGIN@267 at line 267 of IO/Handle.pm
# once (44µs+3µs) by IO::Seekable::BEGIN@98 at line 98 of IO/Seekable.pm
# once (44µs+2µs) by SelectSaver::BEGIN@38 at line 38 of SelectSaver.pm
# once (40µs+3µs) by IO::Uncompress::Base::BEGIN@20 at line 20 of IO/Uncompress/Base.pm
# once (40µs+3µs) by IO::File::BEGIN@133 at line 133 of IO/File.pm
# once (40µs+2µs) by IO::BEGIN@6 at line 6 of IO.pm
# once (40µs+3µs) by SelectSaver::BEGIN@39 at line 39 of SelectSaver.pm
# once (38µs+2µs) by OpenBSD::Temp::BEGIN@23 at line 23 of OpenBSD/Temp.pm
# once (40µs+0s) by Cwd::BEGIN@3 at line 3 of Cwd.pm
# once (36µs+2µs) by IO::Uncompress::Base::BEGIN@23 at line 23 of IO/Uncompress/Base.pm
# once (33µs+2µs) by OpenBSD::PkgInfo::BEGIN@179 at line 179 of OpenBSD/PkgInfo.pm
# once (30µs+0s) by main::BEGIN@22 at line 22 of OpenBSD/PkgInfo.pm
# once (25µs+0s) by IO::Uncompress::Gunzip::BEGIN@12 at line 12 of IO/Uncompress/Gunzip.pm
# once (25µs+0s) by IO::Uncompress::RawInflate::BEGIN@11 at line 11 of IO/Uncompress/RawInflate.pm
# once (10µs+0s) by OpenBSD::MkTemp::BEGIN@7 at line 7 of OpenBSD/MkTemp.pm | ||||
| 29 | 50 | 75µs | my $pkg = shift; | ||
| 30 | 50 | 66µs | my $callpkg = caller($ExportLevel); | ||
| 31 | |||||
| 32 | 50 | 52µs | if ($pkg eq "Exporter" and @_ and $_[0] eq "import") { | ||
| 33 | 1 | 4µs | *{$callpkg."::import"} = \&import; | ||
| 34 | 1 | 4µs | return; | ||
| 35 | } | ||||
| 36 | |||||
| 37 | # We *need* to treat @{"$pkg\::EXPORT_FAIL"} since Carp uses it :-( | ||||
| 38 | 49 | 169µs | my $exports = \@{"$pkg\::EXPORT"}; | ||
| 39 | # But, avoid creating things if they don't exist, which saves a couple of | ||||
| 40 | # hundred bytes per package processed. | ||||
| 41 | 49 | 122µs | my $fail = ${$pkg . '::'}{EXPORT_FAIL} && \@{"$pkg\::EXPORT_FAIL"}; | ||
| 42 | 49 | 62µs | return export $pkg, $callpkg, @_ | ||
| 43 | if $Verbose or $Debug or $fail && @$fail > 1; | ||||
| 44 | 49 | 91µs | my $export_cache = ($Cache{$pkg} ||= {}); | ||
| 45 | 49 | 136µs | my $args = @_ or @_ = @$exports; | ||
| 46 | |||||
| 47 | 49 | 44µs | if ($args and not %$export_cache) { | ||
| 48 | s/^&//, $export_cache->{$_} = 1 | ||||
| 49 | 7 | 1.33ms | 284 | 195µs | foreach (@$exports, @{"$pkg\::EXPORT_OK"}); # spent 195µs making 284 calls to Exporter::CORE:subst, avg 687ns/call |
| 50 | } | ||||
| 51 | 49 | 34µs | my $heavy; | ||
| 52 | # Try very hard not to use {} and hence have to enter scope on the foreach | ||||
| 53 | # We bomb out of the loop with last as soon as heavy is set. | ||||
| 54 | 49 | 74µs | if ($args or $fail) { | ||
| 55 | ($heavy = (/\W/ or $args and not exists $export_cache->{$_} | ||||
| 56 | or $fail and @$fail and $_ eq $fail->[0])) and last | ||||
| 57 | 25 | 640µs | 140 | 165µs | foreach (@_); # spent 165µs making 140 calls to Exporter::CORE:match, avg 1µs/call |
| 58 | } else { | ||||
| 59 | ($heavy = /\W/) and last | ||||
| 60 | 24 | 5.85ms | 215 | 183µs | foreach (@_); # spent 183µs making 215 calls to Exporter::CORE:match, avg 850ns/call |
| 61 | } | ||||
| 62 | 49 | 111µs | 8 | 1.79ms | return export $pkg, $callpkg, ($args ? @_ : ()) if $heavy; # spent 1.79ms making 8 calls to Exporter::export, avg 223µs/call |
| 63 | local $SIG{__WARN__} = | ||||
| 64 | 41 | 299µs | sub {require Carp; &Carp::carp} if not $SIG{__WARN__}; | ||
| 65 | # shortcut for the common case of no type character | ||||
| 66 | 41 | 1.59ms | *{"$callpkg\::$_"} = \&{"$pkg\::$_"} foreach @_; | ||
| 67 | } | ||||
| 68 | |||||
| 69 | # Default methods | ||||
| 70 | |||||
| 71 | sub export_fail { | ||||
| 72 | my $self = shift; | ||||
| 73 | @_; | ||||
| 74 | } | ||||
| 75 | |||||
| 76 | # Unfortunately, caller(1)[3] "does not work" if the caller is aliased as | ||||
| 77 | # *name = \&foo. Thus the need to create a lot of identical subroutines | ||||
| 78 | # Otherwise we could have aliased them to export(). | ||||
| 79 | |||||
| 80 | sub export_to_level { | ||||
| 81 | goto &{as_heavy()}; | ||||
| 82 | } | ||||
| 83 | |||||
| 84 | sub export_tags { | ||||
| 85 | goto &{as_heavy()}; | ||||
| 86 | } | ||||
| 87 | |||||
| 88 | # spent 58µs (18+41) within Exporter::export_ok_tags which was called 2 times, avg 29µs/call:
# once (10µs+20µs) by OpenBSD::PackageRepository::uncompress at line 27 of IO/Uncompress/Gunzip.pm
# once (8µs+21µs) by IO::Uncompress::Gunzip::BEGIN@12 at line 25 of IO/Uncompress/RawInflate.pm | ||||
| 89 | 2 | 21µs | 4 | 86µs | goto &{as_heavy()}; # spent 46µs making 2 calls to Exporter::Heavy::heavy_export_ok_tags, avg 23µs/call
# spent 41µs making 2 calls to Exporter::as_heavy, avg 20µs/call |
| 90 | } | ||||
| 91 | |||||
| 92 | sub require_version { | ||||
| 93 | goto &{as_heavy()}; | ||||
| 94 | } | ||||
| 95 | |||||
| 96 | 1 | 12µs | 1; | ||
| 97 | __END__ | ||||
sub Exporter::CORE:match; # opcode | |||||
sub Exporter::CORE:subst; # opcode |