Filename | /home/ss5/perl5/perlbrew/perls/perl-5.14.1/lib/5.14.1/Exporter.pm |
Statements | Executed 670 statements in 11.8ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
41 | 41 | 23 | 9.47ms | 13.1ms | import | Exporter::
9 | 2 | 1 | 6.81ms | 7.21ms | as_heavy | Exporter::
192 | 2 | 1 | 477µs | 477µs | CORE:match (opcode) | Exporter::
267 | 2 | 1 | 426µs | 426µs | CORE:subst (opcode) | Exporter::
7 | 4 | 3 | 119µs | 472µs | export | Exporter::
2 | 2 | 2 | 54µs | 6.91ms | 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 | 65µs | require 5.006; | ||
4 | |||||
5 | # Be lean. | ||||
6 | #use strict; | ||||
7 | #no strict 'refs'; | ||||
8 | |||||
9 | 1 | 2µs | our $Debug = 0; | ||
10 | 1 | 800ns | our $ExportLevel = 0; | ||
11 | 1 | 2µs | our $Verbose ||= 0; | ||
12 | 1 | 2µs | our $VERSION = '5.66'; | ||
13 | 1 | 2µs | our (%Cache); | ||
14 | |||||
15 | sub as_heavy { | ||||
16 | 36 | 929µ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 | 9 | 128µs | $c =~ s/.*:://; # spent 128µs making 9 calls to Exporter::CORE:subst, avg 14µs/call | ||
21 | \&{"Exporter::Heavy::heavy_$c"}; | ||||
22 | } | ||||
23 | |||||
24 | # spent 472µs (119+353) within Exporter::export which was called 7 times, avg 67µs/call:
# 3 times (57µs+203µs) by Exporter::import at line 62, avg 86µs/call
# 2 times (32µs+63µs) by Exporter::Heavy::heavy_export_to_level at line 214 of Exporter/Heavy.pm, avg 48µs/call
# once (17µs+55µs) by FileHandle::import at line 73 of FileHandle.pm
# once (13µs+32µs) by FileHandle::import at line 81 of FileHandle.pm | ||||
25 | 7 | 172µs | 14 | 6.28ms | goto &{as_heavy()}; # spent 5.93ms making 7 calls to Exporter::Heavy::heavy_export, avg 847µs/call
# spent 353µs making 7 calls to Exporter::as_heavy, avg 50µs/call |
26 | } | ||||
27 | |||||
28 | # spent 13.1ms (9.47+3.65) within Exporter::import which was called 41 times, avg 320µs/call:
# once (121µs+1.73ms) by English::import at line 74 of English.pm
# once (1.13ms+164µs) by IO::Seekable::BEGIN@104 at line 104 of IO/Seekable.pm
# once (245µs+807µs) by File::Glob::import at line 45 of File/Glob.pm
# once (789µs+75µs) by main::BEGIN@8 at line 8 of t/app_dpath.t
# once (749µs+53µs) by Config::General::BEGIN@19 at line 148 of IO/File.pm
# once (620µs+68µs) by Config::General::BEGIN@20 at line 39 of FileHandle.pm
# once (516µs+53µs) by Config::General::BEGIN@19 at line 19 of Config/General.pm
# once (90µs+388µs) by Storable::BEGIN@51 at line 52 of Storable.pm
# once (313µs+30µs) by Config::General::BEGIN@21 at line 21 of Config/General.pm
# once (266µs+29µs) by Data::Structure::Util::BEGIN@8 at line 8 of Data/Structure/Util.pm
# once (249µs+22µs) by main::BEGIN@13 at line 13 of t/app_dpath.t
# once (242µs+24µs) by Test::Deep::Cache::Simple::BEGIN@7 at line 7 of Test/Deep/Cache/Simple.pm
# once (210µs+15µs) by Data::Dumper::BEGIN@20 at line 20 of Data/Dumper.pm
# once (194µs+19µs) by Test::Deep::BEGIN@5 at line 5 of Test/Deep.pm
# once (197µs+13µs) by main::BEGIN@10 at line 10 of t/app_dpath.t
# once (188µs+10µs) by IO::Seekable::BEGIN@98 at line 98 of IO/Seekable.pm
# once (184µs+13µs) by IO::File::BEGIN@131 at line 131 of IO/File.pm
# once (184µs+13µs) by Data::Structure::Util::BEGIN@9 at line 9 of Data/Structure/Util.pm
# once (173µs+15µs) by Test::Deep::Ref::BEGIN@8 at line 8 of Test/Deep/Ref.pm
# once (174µs+11µs) by IO::File::BEGIN@130 at line 130 of IO/File.pm
# once (159µs+10µs) by IO::Handle::BEGIN@263 at line 263 of IO/Handle.pm
# once (159µs+9µs) by Config::General::BEGIN@32 at line 32 of Config/General.pm
# once (159µs+8µs) by SelectSaver::BEGIN@38 at line 38 of SelectSaver.pm
# once (162µs+0s) by Test::Deep::Cmp::BEGIN@12 at line 12 of Test/Deep/Cmp.pm
# once (148µs+7µs) by IO::Handle::BEGIN@264 at line 264 of IO/Handle.pm
# once (148µs+5µs) by Test::Deep::RefType::BEGIN@8 at line 8 of Test/Deep/RefType.pm
# once (145µs+5µs) by Test::Deep::Shallow::BEGIN@8 at line 8 of Test/Deep/Shallow.pm
# once (137µs+10µs) by IO::File::BEGIN@133 at line 133 of IO/File.pm
# once (136µs+9µs) by main::BEGIN@6 at line 6 of t/app_dpath.t
# once (137µs+6µs) by Test::Deep::Blessed::BEGIN@8 at line 8 of Test/Deep/Blessed.pm
# once (131µs+7µs) by Test::Deep::Stack::BEGIN@6 at line 6 of Test/Deep/Stack.pm
# once (128µs+8µs) by IO::BEGIN@6 at line 6 of IO.pm
# once (123µs+8µs) by SelectSaver::BEGIN@39 at line 39 of SelectSaver.pm
# once (123µs+6µs) by Test::Deep::Cache::Simple::BEGIN@10 at line 19 of Test/Deep/Cache/Simple.pm
# once (118µs+0s) by main::BEGIN@11 at line 11 of t/app_dpath.t
# once (109µs+5µs) by Test::Deep::Cache::Simple::BEGIN@5 at line 5 of Test/Deep/Cache/Simple.pm
# once (103µs+0s) by JSON::XS::BEGIN@121 at line 121 of JSON/XS.pm
# once (100µs+0s) by Test::Deep::BEGIN@12 at line 12 of Test/Deep.pm
# once (85µs+0s) by YAML::Syck::BEGIN@13 at line 13 of YAML/Syck.pm
# once (68µs+0s) by Test::Deep::Stack::BEGIN@7 at line 7 of Test/Deep/Stack.pm
# once (55µs+0s) by Config::General::BEGIN@33 at line 33 of Config/General.pm | ||||
29 | 568 | 6.04ms | 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 = \@{"$pkg\::EXPORT"}; | ||||
39 | # But, avoid creating things if they don't exist, which saves a couple of | ||||
40 | # hundred bytes per package processed. | ||||
41 | my $fail = ${$pkg . '::'}{EXPORT_FAIL} && \@{"$pkg\::EXPORT_FAIL"}; | ||||
42 | return export $pkg, $callpkg, @_ | ||||
43 | if $Verbose or $Debug or $fail && @$fail > 1; | ||||
44 | my $export_cache = ($Cache{$pkg} ||= {}); | ||||
45 | my $args = @_ or @_ = @$exports; | ||||
46 | |||||
47 | 9 | 2.22ms | if ($args and not %$export_cache) { | ||
48 | s/^&//, $export_cache->{$_} = 1 | ||||
49 | 258 | 298µs | foreach (@$exports, @{"$pkg\::EXPORT_OK"}); # spent 298µs making 258 calls to Exporter::CORE:subst, avg 1µs/call | ||
50 | } | ||||
51 | 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 | 41 | 2.30ms | 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 | 92 | 283µs | foreach (@_); # spent 283µs making 92 calls to Exporter::CORE:match, avg 3µs/call | ||
58 | } else { | ||||
59 | ($heavy = /\W/) and last | ||||
60 | 100 | 195µs | foreach (@_); # spent 195µs making 100 calls to Exporter::CORE:match, avg 2µs/call | ||
61 | } | ||||
62 | 3 | 259µs | return export $pkg, $callpkg, ($args ? @_ : ()) if $heavy; # spent 259µs making 3 calls to Exporter::export, avg 86µs/call | ||
63 | local $SIG{__WARN__} = | ||||
64 | sub {require Carp; &Carp::carp} if not $SIG{__WARN__}; | ||||
65 | # shortcut for the common case of no type character | ||||
66 | *{"$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 6.91ms (54µs+6.85) within Exporter::export_to_level which was called 2 times, avg 3.45ms/call:
# once (35µs+6.79ms) by Test::Builder::Module::import at line 93 of Test/Builder/Module.pm
# once (19µs+62µs) by JSON::import at line 111 of JSON.pm | ||||
81 | 2 | 82µs | 4 | 8.13ms | goto &{as_heavy()}; # spent 6.85ms making 2 calls to Exporter::as_heavy, avg 3.43ms/call
# spent 1.27ms making 2 calls to Exporter::Heavy::heavy_export_to_level, avg 636µs/call |
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 | 20µs | 1; | ||
97 | __END__ | ||||
sub Exporter::CORE:match; # opcode | |||||
sub Exporter::CORE:subst; # opcode |