Filename | /usr/share/perl5/core_perl/Exporter.pm |
Statements | Executed 190 statements in 1.47ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
12 | 10 | 6 | 1.28ms | 1.35ms | import | Exporter::
24 | 2 | 1 | 44µs | 44µs | CORE:match (opcode) | Exporter::
59 | 1 | 1 | 27µs | 27µs | CORE:subst (opcode) | Exporter::
0 | 0 | 0 | 0s | 0s | __ANON__[:64] | Exporter::
0 | 0 | 0 | 0s | 0s | as_heavy | Exporter::
0 | 0 | 0 | 0s | 0s | export | Exporter::
0 | 0 | 0 | 0s | 0s | export_fail | Exporter::
0 | 0 | 0 | 0s | 0s | export_ok_tags | Exporter::
0 | 0 | 0 | 0s | 0s | export_tags | Exporter::
0 | 0 | 0 | 0s | 0s | export_to_level | Exporter::
0 | 0 | 0 | 0s | 0s | require_version | Exporter::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | package Exporter; | ||||
2 | |||||
3 | 1 | 26µs | require 5.006; | ||
4 | |||||
5 | # Be lean. | ||||
6 | #use strict; | ||||
7 | #no strict 'refs'; | ||||
8 | |||||
9 | 1 | 900ns | our $Debug = 0; | ||
10 | 1 | 400ns | our $ExportLevel = 0; | ||
11 | 1 | 700ns | our $Verbose ||= 0; | ||
12 | 1 | 1µs | our $VERSION = '5.68'; | ||
13 | 1 | 600ns | 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 1.35ms (1.28+71µs) within Exporter::import which was called 12 times, avg 113µs/call:
# 3 times (273µs+15µs) by Runner::BEGIN@14 or Runner::IO::BEGIN@6 or Runner::Stats::BEGIN@7 at line 34 of List/Util.pm, avg 96µs/call
# once (199µs+14µs) by Runner::Stats::BEGIN@8 at line 8 of Runner/Stats.pm
# once (125µs+5µs) by Runner::BEGIN@10 at line 10 of runner.pl
# once (123µs+7µs) by Data::Dumper::BEGIN@22 at line 22 of Data/Dumper.pm
# once (119µs+6µs) by Runner::BEGIN@11 at line 11 of runner.pl
# once (117µs+5µs) by Runner::BEGIN@12 at line 12 of runner.pl
# once (110µs+10µs) by Runner::BEGIN@13 at line 13 of runner.pl
# once (87µs+5µs) by Runner::IO::BEGIN@5 at line 5 of Runner/IO.pm
# once (72µs+3µs) by Runner::Stats::BEGIN@5 at line 5 of Runner/Stats.pm
# once (57µs+0s) by JSON::XS::BEGIN@121 at line 121 of JSON/XS.pm | ||||
29 | 12 | 14µs | my $pkg = shift; | ||
30 | 12 | 25µs | my $callpkg = caller($ExportLevel); | ||
31 | |||||
32 | 12 | 14µ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 | 12 | 62µ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 | 12 | 38µs | my $fail = ${$pkg . '::'}{EXPORT_FAIL} && \@{"$pkg\::EXPORT_FAIL"}; | ||
42 | 12 | 16µs | return export $pkg, $callpkg, @_ | ||
43 | if $Verbose or $Debug or $fail && @$fail > 1; | ||||
44 | 12 | 29µs | my $export_cache = ($Cache{$pkg} ||= {}); | ||
45 | 12 | 35µs | my $args = @_ or @_ = @$exports; | ||
46 | |||||
47 | 12 | 13µs | if ($args and not %$export_cache) { | ||
48 | s/^&//, $export_cache->{$_} = 1 | ||||
49 | 3 | 281µs | 59 | 27µs | foreach (@$exports, @{"$pkg\::EXPORT_OK"}); # spent 27µs making 59 calls to Exporter::CORE:subst, avg 458ns/call |
50 | } | ||||
51 | 12 | 4µ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 | 12 | 21µ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 | 7 | 158µs | 17 | 27µs | foreach (@_); # spent 27µs making 17 calls to Exporter::CORE:match, avg 2µs/call |
58 | } else { | ||||
59 | ($heavy = /\W/) and last | ||||
60 | 5 | 102µs | 7 | 17µs | foreach (@_); # spent 17µs making 7 calls to Exporter::CORE:match, avg 2µs/call |
61 | } | ||||
62 | 12 | 5µs | return export $pkg, $callpkg, ($args ? @_ : ()) if $heavy; | ||
63 | local $SIG{__WARN__} = | ||||
64 | 12 | 171µs | sub {require Carp; &Carp::carp} if not $SIG{__WARN__}; | ||
65 | # shortcut for the common case of no type character | ||||
66 | 12 | 437µ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 | 12µs | 1; | ||
97 | __END__ | ||||
sub Exporter::CORE:match; # opcode | |||||
# spent 27µs within Exporter::CORE:subst which was called 59 times, avg 458ns/call:
# 59 times (27µs+0s) by Exporter::import at line 49, avg 458ns/call |