| Filename | /home/leont/perl5/perlbrew/perls/perl-5.32.0/lib/5.32.0/Exporter.pm |
| Statements | Executed 98 statements in 116µs |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 6 | 6 | 4 | 94µs | 103µs | Exporter::import |
| 21 | 1 | 1 | 6µs | 6µs | Exporter::CORE:subst (opcode) |
| 7 | 1 | 1 | 4µs | 4µs | Exporter::CORE:match (opcode) |
| 0 | 0 | 0 | 0s | 0s | Exporter::__ANON__[:64] |
| 0 | 0 | 0 | 0s | 0s | Exporter::as_heavy |
| 0 | 0 | 0 | 0s | 0s | Exporter::export |
| 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 | 4µs | require 5.006; | ||
| 4 | |||||
| 5 | # Be lean. | ||||
| 6 | #use strict; | ||||
| 7 | #no strict 'refs'; | ||||
| 8 | |||||
| 9 | 1 | 200ns | our $Debug = 0; | ||
| 10 | 1 | 0s | our $ExportLevel = 0; | ||
| 11 | 1 | 200ns | our $Verbose ||= 0; | ||
| 12 | 1 | 100ns | our $VERSION = '5.74'; | ||
| 13 | our (%Cache); | ||||
| 14 | |||||
| 15 | sub as_heavy { | ||||
| 16 | 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 | my $c = (caller(1))[3]; | ||||
| 20 | $c =~ s/.*:://; | ||||
| 21 | \&{"Exporter::Heavy::heavy_$c"}; | ||||
| 22 | } | ||||
| 23 | |||||
| 24 | sub export { | ||||
| 25 | goto &{as_heavy()}; | ||||
| 26 | } | ||||
| 27 | |||||
| 28 | # spent 103µs (94+10) within Exporter::import which was called 6 times, avg 17µs/call:
# once (27µs+3µs) by experimental::BEGIN@8 at line 8 of experimental.pm
# once (23µs+4µs) by CPAN::Meta::Prereqs::BEGIN@17 at line 17 of CPAN/Meta/Prereqs.pm
# once (14µs+1µs) by CPAN::Meta::BEGIN@56 at line 56 of CPAN/Meta.pm
# once (12µs+900ns) by CPAN::Meta::Prereqs::BEGIN@16 at line 16 of CPAN/Meta/Prereqs.pm
# once (9µs+900ns) by Parse::CPAN::Meta::BEGIN@10 at line 10 of Parse/CPAN/Meta.pm
# once (8µs+0s) by Parse::CPAN::Meta::BEGIN@9 at line 9 of Parse/CPAN/Meta.pm | ||||
| 29 | 6 | 2µs | my $pkg = shift; | ||
| 30 | 6 | 2µs | my $callpkg = caller($ExportLevel); | ||
| 31 | |||||
| 32 | 6 | 1µs | if ($pkg eq "Exporter" and @_ and $_[0] eq "import") { | ||
| 33 | *{$callpkg."::import"} = \&import; | ||||
| 34 | return; | ||||
| 35 | } | ||||
| 36 | |||||
| 37 | # We *need* to treat @{"$pkg\::EXPORT_FAIL"} since Carp uses it :-( | ||||
| 38 | 6 | 5µ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 | 6 | 5µs | my $fail = ${$pkg . '::'}{EXPORT_FAIL} && \@{"$pkg\::EXPORT_FAIL"}; | ||
| 42 | 6 | 2µs | return export $pkg, $callpkg, @_ | ||
| 43 | if $Verbose or $Debug or $fail && @$fail > 1; | ||||
| 44 | 6 | 2µs | my $export_cache = ($Cache{$pkg} ||= {}); | ||
| 45 | 6 | 1µs | my $args = @_ or @_ = @$exports; | ||
| 46 | |||||
| 47 | 6 | 1µs | if ($args and not %$export_cache) { | ||
| 48 | s/^&//, $export_cache->{$_} = 1 | ||||
| 49 | 2 | 27µs | 21 | 6µs | foreach (@$exports, @{"$pkg\::EXPORT_OK"}); # spent 6µs making 21 calls to Exporter::CORE:subst, avg 262ns/call |
| 50 | } | ||||
| 51 | 6 | 400ns | 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 | 6 | 1µ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 | 5 | 17µs | 7 | 4µs | foreach (@_); # spent 4µs making 7 calls to Exporter::CORE:match, avg 614ns/call |
| 58 | } else { | ||||
| 59 | ($heavy = /\W/) and last | ||||
| 60 | 1 | 200ns | foreach (@_); | ||
| 61 | } | ||||
| 62 | 6 | 400ns | return export $pkg, $callpkg, ($args ? @_ : ()) if $heavy; | ||
| 63 | local $SIG{__WARN__} = | ||||
| 64 | 6 | 15µs | sub {require Carp; &Carp::carp} if not $SIG{__WARN__}; | ||
| 65 | # shortcut for the common case of no type character | ||||
| 66 | 6 | 27µ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 | 3µs | 1; | ||
| 97 | __END__ | ||||
# spent 4µs within Exporter::CORE:match which was called 7 times, avg 614ns/call:
# 7 times (4µs+0s) by Exporter::import at line 57, avg 614ns/call | |||||
# spent 6µs within Exporter::CORE:subst which was called 21 times, avg 262ns/call:
# 21 times (6µs+0s) by Exporter::import at line 49, avg 262ns/call |