| Filename | /usr/libdata/perl5/Exporter.pm |
| Statements | Executed 274 statements in 2.03ms |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 18 | 18 | 10 | 1.60ms | 3.58ms | Exporter::import |
| 2 | 1 | 1 | 1.51ms | 1.60ms | Exporter::as_heavy |
| 174 | 2 | 1 | 115µs | 115µs | Exporter::CORE:subst (opcode) |
| 112 | 2 | 1 | 90µs | 90µs | Exporter::CORE:match (opcode) |
| 2 | 1 | 1 | 14µs | 1.61ms | Exporter::export |
| 0 | 0 | 0 | 0s | 0s | Exporter::__ANON__[:64] |
| 0 | 0 | 0 | 0s | 0s | Exporter::export_fail |
| 0 | 0 | 0 | 0s | 0s | Exporter::export_ok_tags |
| 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 | 8µs | require 5.006; | ||
| 4 | |||||
| 5 | # Be lean. | ||||
| 6 | #use strict; | ||||
| 7 | #no strict 'refs'; | ||||
| 8 | |||||
| 9 | 1 | 700ns | our $Debug = 0; | ||
| 10 | 1 | 600ns | our $ExportLevel = 0; | ||
| 11 | 1 | 700ns | our $Verbose ||= 0; | ||
| 12 | 1 | 800ns | our $VERSION = '5.72'; | ||
| 13 | our (%Cache); | ||||
| 14 | |||||
| 15 | # spent 1.60ms (1.51+92µs) within Exporter::as_heavy which was called 2 times, avg 800µs/call:
# 2 times (1.51ms+92µs) by Exporter::export at line 25, avg 800µs/call | ||||
| 16 | 2 | 130µ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 | 2 | 8µs | my $c = (caller(1))[3]; | ||
| 20 | 2 | 16µs | 2 | 7µs | $c =~ s/.*:://; # spent 7µs making 2 calls to Exporter::CORE:subst, avg 4µs/call |
| 21 | 2 | 11µs | \&{"Exporter::Heavy::heavy_$c"}; | ||
| 22 | } | ||||
| 23 | |||||
| 24 | # spent 1.61ms (14µs+1.60) within Exporter::export which was called 2 times, avg 807µs/call:
# 2 times (14µs+1.60ms) by Exporter::import at line 62, avg 807µs/call | ||||
| 25 | 2 | 27µs | 4 | 1.77ms | goto &{as_heavy()}; # spent 1.60ms making 2 calls to Exporter::as_heavy, avg 800µs/call
# spent 167µs making 2 calls to Exporter::Heavy::heavy_export, avg 84µs/call |
| 26 | } | ||||
| 27 | |||||
| 28 | # spent 3.58ms (1.60+1.98) within Exporter::import which was called 18 times, avg 199µs/call:
# once (411µs+1.81ms) by OpenBSD::PackageInfo::BEGIN@39 at line 39 of OpenBSD/PackageInfo.pm
# once (210µs+19µs) by OpenBSD::PackageRepository::Installed::BEGIN@197 at line 198 of OpenBSD/PackageRepository/Installed.pm
# once (127µs+13µs) by OpenBSD::PackageLocation::BEGIN@23 at line 23 of OpenBSD/PackageLocation.pm
# once (116µs+13µs) by OpenBSD::PkgInfo::BEGIN@177 at line 177 of OpenBSD/PkgInfo.pm
# once (114µs+12µs) by OpenBSD::PkgInfo::State::BEGIN@65 at line 65 of OpenBSD/PkgInfo.pm
# once (24µs+65µs) by OpenBSD::Getopt::getopts at line 85 of OpenBSD/Getopt.pm
# once (77µs+3µs) by OpenBSD::State::BEGIN@86 at line 86 of OpenBSD/State.pm
# once (69µs+5µs) by OpenBSD::PackageRepository::Local::BEGIN@454 at line 454 of OpenBSD/PackageRepository.pm
# once (62µs+5µs) by OpenBSD::State::BEGIN@88 at line 88 of OpenBSD/State.pm
# once (60µs+6µ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+5µs) by OpenBSD::Temp::BEGIN@25 at line 25 of OpenBSD/Temp.pm
# once (58µs+5µs) by OpenBSD::PkgInfo::BEGIN@180 at line 180 of OpenBSD/PkgInfo.pm
# once (44µs+3µs) by OpenBSD::Error::BEGIN@72 at line 72 of OpenBSD/Error.pm
# once (38µs+2µs) by OpenBSD::Temp::BEGIN@23 at line 23 of OpenBSD/Temp.pm
# once (34µs+2µs) by OpenBSD::PkgInfo::BEGIN@179 at line 179 of OpenBSD/PkgInfo.pm
# once (24µs+0s) by main::BEGIN@22 at line 22 of OpenBSD/PkgInfo.pm
# once (10µs+0s) by OpenBSD::MkTemp::BEGIN@7 at line 7 of OpenBSD/MkTemp.pm | ||||
| 29 | 18 | 17µs | my $pkg = shift; | ||
| 30 | 18 | 19µs | my $callpkg = caller($ExportLevel); | ||
| 31 | |||||
| 32 | 18 | 17µs | if ($pkg eq "Exporter" and @_ and $_[0] eq "import") { | ||
| 33 | 1 | 3µs | *{$callpkg."::import"} = \&import; | ||
| 34 | 1 | 4µs | return; | ||
| 35 | } | ||||
| 36 | |||||
| 37 | # We *need* to treat @{"$pkg\::EXPORT_FAIL"} since Carp uses it :-( | ||||
| 38 | 17 | 40µ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 | 17 | 27µs | my $fail = ${$pkg . '::'}{EXPORT_FAIL} && \@{"$pkg\::EXPORT_FAIL"}; | ||
| 42 | 17 | 14µs | return export $pkg, $callpkg, @_ | ||
| 43 | if $Verbose or $Debug or $fail && @$fail > 1; | ||||
| 44 | 17 | 20µs | my $export_cache = ($Cache{$pkg} ||= {}); | ||
| 45 | 17 | 51µs | my $args = @_ or @_ = @$exports; | ||
| 46 | |||||
| 47 | 17 | 13µs | if ($args and not %$export_cache) { | ||
| 48 | s/^&//, $export_cache->{$_} = 1 | ||||
| 49 | 2 | 618µs | 172 | 107µs | foreach (@$exports, @{"$pkg\::EXPORT_OK"}); # spent 107µs making 172 calls to Exporter::CORE:subst, avg 624ns/call |
| 50 | } | ||||
| 51 | 17 | 11µ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 | 17 | 24µ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 | 4 | 67µs | 12 | 15µs | foreach (@_); # spent 15µs making 12 calls to Exporter::CORE:match, avg 1µs/call |
| 58 | } else { | ||||
| 59 | ($heavy = /\W/) and last | ||||
| 60 | 13 | 334µs | 100 | 75µs | foreach (@_); # spent 75µs making 100 calls to Exporter::CORE:match, avg 747ns/call |
| 61 | } | ||||
| 62 | 17 | 24µs | 2 | 1.61ms | return export $pkg, $callpkg, ($args ? @_ : ()) if $heavy; # spent 1.61ms making 2 calls to Exporter::export, avg 807µs/call |
| 63 | local $SIG{__WARN__} = | ||||
| 64 | 15 | 86µs | sub {require Carp; &Carp::carp} if not $SIG{__WARN__}; | ||
| 65 | # shortcut for the common case of no type character | ||||
| 66 | 15 | 436µs | *{"$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 | sub export_ok_tags { | ||||
| 89 | goto &{as_heavy()}; | ||||
| 90 | } | ||||
| 91 | |||||
| 92 | sub require_version { | ||||
| 93 | goto &{as_heavy()}; | ||||
| 94 | } | ||||
| 95 | |||||
| 96 | 1 | 5µs | 1; | ||
| 97 | __END__ | ||||
sub Exporter::CORE:match; # opcode | |||||
sub Exporter::CORE:subst; # opcode |