Filename | /usr/lib/perl5/5.12.4/Exporter.pm |
Statements | Executed 289 statements in 13.0ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
16 | 16 | 11 | 10.4ms | 40.3ms | import | Exporter::
1 | 1 | 1 | 7.40ms | 7.84ms | as_heavy | Exporter::
208 | 1 | 1 | 885µs | 885µs | CORE:match (opcode) | Exporter::
185 | 2 | 1 | 662µs | 662µs | CORE:subst (opcode) | Exporter::
1 | 1 | 1 | 41µs | 7.88ms | export | Exporter::
0 | 0 | 0 | 0s | 0s | __ANON__[:62] | 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 | 107µs | require 5.006; | ||
4 | |||||
5 | # Be lean. | ||||
6 | #use strict; | ||||
7 | #no strict 'refs'; | ||||
8 | |||||
9 | 1 | 4µs | our $Debug = 0; | ||
10 | 1 | 2µs | our $ExportLevel = 0; | ||
11 | 1 | 3µs | our $Verbose ||= 0; | ||
12 | 1 | 4µs | our $VERSION = '5.64_01'; | ||
13 | 1 | 3µs | our (%Cache); | ||
14 | |||||
15 | # spent 7.84ms (7.40+449µs) within Exporter::as_heavy which was called:
# once (7.40ms+449µs) by Exporter::export at line 25 | ||||
16 | 4 | 638µ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 | my $c = (caller(1))[3]; | ||||
20 | 1 | 22µs | $c =~ s/.*:://; # spent 22µs making 1 call to Exporter::CORE:subst | ||
21 | \&{"Exporter::Heavy::heavy_$c"}; | ||||
22 | } | ||||
23 | |||||
24 | # spent 7.88ms (41µs+7.84) within Exporter::export which was called:
# once (41µs+7.84ms) by Exporter::import at line 60 | ||||
25 | 1 | 47µs | 2 | 28.4ms | goto &{as_heavy()}; # spent 20.5ms making 1 call to Exporter::Heavy::heavy_export
# spent 7.84ms making 1 call to Exporter::as_heavy |
26 | } | ||||
27 | |||||
28 | # spent 40.3ms (10.4+29.9) within Exporter::import which was called 16 times, avg 2.52ms/call:
# once (2.23ms+28.9ms) by POSIX::import at line 29 of POSIX.pm
# once (3.49ms+702µs) by POSIX::BEGIN@13 at line 13 of POSIX.pm
# once (574µs+50µs) by Params::Validate::BEGIN@13 at line 13 of Params/Validate.pm
# once (542µs+53µs) by DateTime::BEGIN@47 at line 47 of DateTime.pm
# once (516µs+67µs) by DateTime::Duration::BEGIN@12 at line 12 of DateTime/Duration.pm
# once (375µs+33µs) by DateTime::BEGIN@48 at line 49 of DateTime.pm
# once (354µs+25µs) by DateTime::TimeZone::BEGIN@15 at line 15 of DateTime/TimeZone.pm
# once (313µs+34µs) by DateTime::Locale::Base::BEGIN@6 at line 6 of DateTime/Locale/Base.pm
# once (321µs+18µs) by DateTime::BEGIN@42 at line 42 of DateTime.pm
# once (279µs+14µs) by Try::Tiny::BEGIN@46 at line 46 of Try/Tiny.pm
# once (274µs+19µs) by DateTime::Locale::BEGIN@12 at line 12 of DateTime/Locale.pm
# once (270µs+16µs) by Module::Implementation::BEGIN@10 at line 10 of Module/Implementation.pm
# once (262µs+16µs) by Tie::Hash::BEGIN@188 at line 188 of Tie/Hash.pm
# once (228µs+12µs) by DateTime::TimeZone::OffsetOnly::BEGIN@12 at line 12 of DateTime/TimeZone/OffsetOnly.pm
# once (192µs+9µs) by DateTime::Locale::Base::BEGIN@9 at line 9 of DateTime/Locale/Base.pm
# once (151µs+0s) by Params::Validate::BEGIN@11 at line 11 of Params/Validate.pm | ||||
29 | 237 | 4.65ms | my $pkg = shift; | ||
30 | my $callpkg = caller($ExportLevel); | ||||
31 | |||||
32 | 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 | my($exports, $fail) = (\@{"$pkg\::EXPORT"}, \@{"$pkg\::EXPORT_FAIL"}); | ||||
39 | return export $pkg, $callpkg, @_ | ||||
40 | if $Verbose or $Debug or @$fail > 1; | ||||
41 | my $export_cache = ($Cache{$pkg} ||= {}); | ||||
42 | my $args = @_ or @_ = @$exports; | ||||
43 | |||||
44 | local $_; | ||||
45 | 8 | 3.50ms | if ($args and not %$export_cache) { | ||
46 | s/^&//, $export_cache->{$_} = 1 | ||||
47 | 184 | 640µs | foreach (@$exports, @{"$pkg\::EXPORT_OK"}); # spent 640µs making 184 calls to Exporter::CORE:subst, avg 3µs/call | ||
48 | } | ||||
49 | my $heavy; | ||||
50 | # Try very hard not to use {} and hence have to enter scope on the foreach | ||||
51 | # We bomb out of the loop with last as soon as heavy is set. | ||||
52 | 32 | 4.04ms | if ($args or $fail) { | ||
53 | ($heavy = (/\W/ or $args and not exists $export_cache->{$_} | ||||
54 | or @$fail and $_ eq $fail->[0])) and last | ||||
55 | 208 | 885µs | foreach (@_); # spent 885µs making 208 calls to Exporter::CORE:match, avg 4µs/call | ||
56 | } else { | ||||
57 | ($heavy = /\W/) and last | ||||
58 | foreach (@_); | ||||
59 | } | ||||
60 | 1 | 7.88ms | return export $pkg, $callpkg, ($args ? @_ : ()) if $heavy; # spent 7.88ms making 1 call to Exporter::export | ||
61 | local $SIG{__WARN__} = | ||||
62 | sub {require Carp; &Carp::carp}; | ||||
63 | # shortcut for the common case of no type character | ||||
64 | *{"$callpkg\::$_"} = \&{"$pkg\::$_"} foreach @_; | ||||
65 | } | ||||
66 | |||||
67 | # Default methods | ||||
68 | |||||
69 | sub export_fail { | ||||
70 | my $self = shift; | ||||
71 | @_; | ||||
72 | } | ||||
73 | |||||
74 | # Unfortunately, caller(1)[3] "does not work" if the caller is aliased as | ||||
75 | # *name = \&foo. Thus the need to create a lot of identical subroutines | ||||
76 | # Otherwise we could have aliased them to export(). | ||||
77 | |||||
78 | sub export_to_level { | ||||
79 | goto &{as_heavy()}; | ||||
80 | } | ||||
81 | |||||
82 | sub export_tags { | ||||
83 | goto &{as_heavy()}; | ||||
84 | } | ||||
85 | |||||
86 | sub export_ok_tags { | ||||
87 | goto &{as_heavy()}; | ||||
88 | } | ||||
89 | |||||
90 | sub require_version { | ||||
91 | goto &{as_heavy()}; | ||||
92 | } | ||||
93 | |||||
94 | 1 | 22µs | 1; | ||
95 | __END__ | ||||
# spent 885µs within Exporter::CORE:match which was called 208 times, avg 4µs/call:
# 208 times (885µs+0s) by Exporter::import at line 55, avg 4µs/call | |||||
sub Exporter::CORE:subst; # opcode |