Filename | /usr/lib/perl5/5.20.1/Exporter.pm |
Statements | Executed 348 statements in 1.06ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
23 | 23 | 14 | 895µs | 998µs | import | Exporter::
3 | 2 | 1 | 842µs | 898µs | as_heavy | Exporter::
246 | 2 | 1 | 36µs | 36µs | CORE:match (opcode) | Exporter::
201 | 2 | 1 | 8µs | 8µs | CORE:subst (opcode) | Exporter::
2 | 2 | 2 | 7µs | 18µs | export | Exporter::
1 | 1 | 1 | 3µs | 890µs | export_to_level | Exporter::
0 | 0 | 0 | 0s | 0s | __ANON__[:64] | 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 | require_version | Exporter::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | package Exporter; | ||||
2 | |||||
3 | 1 | 5µs | require 5.006; | ||
4 | |||||
5 | # Be lean. | ||||
6 | #use strict; | ||||
7 | #no strict 'refs'; | ||||
8 | |||||
9 | 1 | 300ns | our $Debug = 0; | ||
10 | 1 | 100ns | our $ExportLevel = 0; | ||
11 | 1 | 200ns | our $Verbose ||= 0; | ||
12 | 1 | 200ns | our $VERSION = '5.71'; | ||
13 | 1 | 200ns | our (%Cache); | ||
14 | |||||
15 | sub as_heavy { | ||||
16 | 3 | 59µ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 | 3 | 4µs | my $c = (caller(1))[3]; | ||
20 | 3 | 13µs | 3 | 6µs | $c =~ s/.*:://; # spent 6µs making 3 calls to Exporter::CORE:subst, avg 2µs/call |
21 | 3 | 7µs | \&{"Exporter::Heavy::heavy_$c"}; | ||
22 | } | ||||
23 | |||||
24 | # spent 18µs (7+12) within Exporter::export which was called 2 times, avg 9µs/call:
# once (5µs+8µs) by Exporter::import at line 62
# once (2µs+4µs) by Exporter::Heavy::heavy_export_to_level at line 219 of Exporter/Heavy.pm | ||||
25 | 2 | 6µs | 4 | 151µs | goto &{as_heavy()}; # spent 139µs making 2 calls to Exporter::Heavy::heavy_export, avg 70µs/call
# spent 12µs making 2 calls to Exporter::as_heavy, avg 6µs/call |
26 | } | ||||
27 | |||||
28 | # spent 998µs (895+103) within Exporter::import which was called 23 times, avg 43µs/call:
# once (143µs+2µs) by IO::Seekable::BEGIN@104 at line 104 of IO/Seekable.pm
# once (97µs+4µs) by Date::Manip::Delta::BEGIN@21 at line 21 of Date/Manip/Delta.pm
# once (79µs+5µs) by Date::Manip::TZ::BEGIN@22 at line 22 of Date/Manip/TZ.pm
# once (10µs+66µs) by Storable::BEGIN@53 at line 54 of Storable.pm
# once (69µs+4µs) by Date::Manip::Date::BEGIN@22 at line 22 of Date/Manip/Date.pm
# once (63µs+3µs) by Date::Manip::Obj::BEGIN@12 at line 147 of IO/File.pm
# once (60µs+4µs) by Date::Manip::TZ_Base::BEGIN@12 at line 12 of Date/Manip/TZ_Base.pm
# once (60µs+1µs) by Date::Manip::Base::BEGIN@24 at line 24 of Date/Manip/Base.pm
# once (54µs+4µs) by Date::Manip::Obj::BEGIN@12 at line 12 of Date/Manip/Obj.pm
# once (50µs+800ns) by Date::Manip::Obj::BEGIN@13 at line 13 of Date/Manip/Obj.pm
# once (30µs+2µs) by IO::File::BEGIN@130 at line 130 of IO/File.pm
# once (22µs+1µs) by IO::File::BEGIN@131 at line 131 of IO/File.pm
# once (21µs+600ns) by Encode::BEGIN@47 at line 47 of Encode.pm
# once (20µs+800ns) by IO::Seekable::BEGIN@98 at line 98 of IO/Seekable.pm
# once (18µs+700ns) by SelectSaver::BEGIN@38 at line 38 of SelectSaver.pm
# once (18µs+700ns) by IO::Handle::BEGIN@266 at line 266 of IO/Handle.pm
# once (17µs+700ns) by IO::Handle::BEGIN@267 at line 267 of IO/Handle.pm
# once (17µs+600ns) by IO::BEGIN@6 at line 6 of IO.pm
# once (16µs+800ns) by IO::File::BEGIN@133 at line 133 of IO/File.pm
# once (14µs+600ns) by SelectSaver::BEGIN@39 at line 39 of SelectSaver.pm
# once (11µs+400ns) by Date::Manip::Date::BEGIN@23 at line 23 of Date/Manip/Date.pm
# once (4µs+0s) by Encode::BEGIN@12 at line 12 of Encode.pm
# once (3µs+0s) by Encode::Alias::BEGIN@8 at line 8 of Encode/Alias.pm | ||||
29 | 23 | 6µs | my $pkg = shift; | ||
30 | 23 | 9µs | my $callpkg = caller($ExportLevel); | ||
31 | |||||
32 | 23 | 6µs | if ($pkg eq "Exporter" and @_ and $_[0] eq "import") { | ||
33 | 2 | 3µs | *{$callpkg."::import"} = \&import; | ||
34 | 2 | 13µs | return; | ||
35 | } | ||||
36 | |||||
37 | # We *need* to treat @{"$pkg\::EXPORT_FAIL"} since Carp uses it :-( | ||||
38 | 21 | 17µ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 | 21 | 13µs | my $fail = ${$pkg . '::'}{EXPORT_FAIL} && \@{"$pkg\::EXPORT_FAIL"}; | ||
42 | 21 | 6µs | return export $pkg, $callpkg, @_ | ||
43 | if $Verbose or $Debug or $fail && @$fail > 1; | ||||
44 | 21 | 11µs | my $export_cache = ($Cache{$pkg} ||= {}); | ||
45 | 21 | 26µs | my $args = @_ or @_ = @$exports; | ||
46 | |||||
47 | 21 | 5µs | if ($args and not %$export_cache) { | ||
48 | s/^&//, $export_cache->{$_} = 1 | ||||
49 | 3 | 189µs | 198 | 2µs | foreach (@$exports, @{"$pkg\::EXPORT_OK"}); # spent 2µs making 198 calls to Exporter::CORE:subst, avg 10ns/call |
50 | } | ||||
51 | 21 | 2µ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 | 21 | 7µ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 | 11 | 81µs | 59 | 12µs | foreach (@_); # spent 12µs making 59 calls to Exporter::CORE:match, avg 202ns/call |
58 | } else { | ||||
59 | ($heavy = /\W/) and last | ||||
60 | 10 | 183µs | 187 | 24µs | foreach (@_); # spent 24µs making 187 calls to Exporter::CORE:match, avg 129ns/call |
61 | } | ||||
62 | 21 | 6µs | 1 | 12µs | return export $pkg, $callpkg, ($args ? @_ : ()) if $heavy; # spent 12µs making 1 call to Exporter::export |
63 | local $SIG{__WARN__} = | ||||
64 | 20 | 53µs | sub {require Carp; &Carp::carp} if not $SIG{__WARN__}; | ||
65 | # shortcut for the common case of no type character | ||||
66 | 20 | 325µ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 | # spent 890µs (3+887) within Exporter::export_to_level which was called:
# once (3µs+887µs) by Time::HiRes::import at line 63 of Time/HiRes.pm | ||||
81 | 1 | 4µs | 2 | 986µs | goto &{as_heavy()}; # spent 887µs making 1 call to Exporter::as_heavy
# spent 99µs making 1 call to Exporter::Heavy::heavy_export_to_level |
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__ | ||||
sub Exporter::CORE:match; # opcode | |||||
sub Exporter::CORE:subst; # opcode |