Filename | /home/ss5/perl5/perlbrew/perls/tapper-perl/lib/5.16.3/Exporter.pm |
Statements | Executed 1073 statements in 3.23ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
68 | 67 | 36 | 2.59ms | 6.68ms | import | Exporter::
9 | 3 | 1 | 1.22ms | 1.32ms | as_heavy | Exporter::
349 | 2 | 1 | 101µs | 101µs | CORE:match (opcode) | Exporter::
317 | 2 | 1 | 90µs | 90µs | CORE:subst (opcode) | Exporter::
7 | 2 | 2 | 49µs | 1.34ms | export | Exporter::
1 | 1 | 1 | 6µs | 18µs | export_to_level | Exporter::
1 | 1 | 1 | 6µs | 20µs | export_ok_tags | Exporter::
0 | 0 | 0 | 0s | 0s | __ANON__[:64] | Exporter::
0 | 0 | 0 | 0s | 0s | export_fail | 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 | 10µ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 | 300ns | our $Verbose ||= 0; | ||
12 | 1 | 500ns | our $VERSION = '5.66'; | ||
13 | 1 | 300ns | our (%Cache); | ||
14 | |||||
15 | sub as_heavy { | ||||
16 | 9 | 79µ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 | 9 | 29µs | my $c = (caller(1))[3]; | ||
20 | 9 | 65µs | 9 | 27µs | $c =~ s/.*:://; # spent 27µs making 9 calls to Exporter::CORE:subst, avg 3µs/call |
21 | 9 | 50µs | \&{"Exporter::Heavy::heavy_$c"}; | ||
22 | } | ||||
23 | |||||
24 | # spent 1.34ms (49µs+1.29) within Exporter::export which was called 7 times, avg 191µs/call:
# 6 times (46µs+1.28ms) by Exporter::import at line 62, avg 222µs/call
# once (3µs+6µs) by Exporter::Heavy::heavy_export_to_level at line 214 of Exporter/Heavy.pm | ||||
25 | 7 | 64µs | 14 | 3.99ms | goto &{as_heavy()}; # spent 2.70ms making 7 calls to Exporter::Heavy::heavy_export, avg 386µs/call
# spent 1.29ms making 7 calls to Exporter::as_heavy, avg 184µs/call |
26 | } | ||||
27 | |||||
28 | # spent 6.68ms (2.59+4.09) within Exporter::import which was called 68 times, avg 98µs/call:
# 2 times (68µs+4µs) by Benchmark::Perl::Formance::BEGIN@16 or Data::DPath::Context::BEGIN@20 at line 34 of List/Util.pm, avg 36µs/call
# once (147µs+2.10ms) by POSIX::import at line 30 of POSIX.pm
# once (31µs+1.30ms) by Getopt::Long::import at line 114 of Getopt/Long.pm
# once (309µs+262µs) by Storable::BEGIN@52 at line 53 of Storable.pm
# once (46µs+154µs) by Safe::BEGIN@46 at line 46 of Safe.pm
# once (142µs+9µs) by Sys::Info::Base::BEGIN@5 at line 5 of Sys/Info/Base.pm
# once (15µs+117µs) by Sys::Info::Base::BEGIN@8 at line 8 of Sys/Info/Base.pm
# once (115µs+6µs) by POSIX::BEGIN@11 at line 11 of POSIX.pm
# once (107µs+4µs) by Sys::Info::Base::BEGIN@5 at line 147 of IO/File.pm
# once (27µs+54µs) by Benchmark::Perl::Formance::BEGIN@22 at line 22 of lib/Benchmark/Perl/Formance.pm
# once (74µs+5µs) by Data::Structure::Util::BEGIN@8 at line 8 of Data/Structure/Util.pm
# once (64µs+4µs) by Data::DPath::Context::BEGIN@16 at line 16 of Data/DPath/Context.pm
# once (53µs+3µs) by Data::DPath::Context::BEGIN@19 at line 19 of Data/DPath/Context.pm
# once (49µs+3µs) by Sys::Info::BEGIN@6 at line 6 of Sys/Info.pm
# once (44µs+7µs) by Data::DPath::Path::BEGIN@17 at line 17 of Data/DPath/Path.pm
# once (46µs+3µs) by Benchmark::Perl::Formance::BEGIN@12 at line 12 of lib/Benchmark/Perl/Formance.pm
# once (41µs+2µs) by Data::DPath::Context::BEGIN@17 at line 17 of Data/DPath/Context.pm
# once (41µs+3µs) by FindBin::BEGIN@83 at line 83 of FindBin.pm
# once (40µs+2µs) by Data::Structure::Util::BEGIN@9 at line 9 of Data/Structure/Util.pm
# once (40µs+2µs) by IO::Handle::BEGIN@263 at line 263 of IO/Handle.pm
# once (37µs+1µs) by Benchmark::Perl::Formance::BEGIN@18 at line 18 of lib/Benchmark/Perl/Formance.pm
# once (35µs+2µs) by Class::XSAccessor::Array::BEGIN@5 at line 5 of Class/XSAccessor/Array.pm
# once (36µs+1µs) by Text::Balanced::BEGIN@343 at line 343 of Text/Balanced.pm
# once (35µs+2µs) by Tie::Hash::BEGIN@188 at line 188 of Tie/Hash.pm
# once (32µs+1µs) by Sub::Install::BEGIN@6 at line 6 of Sub/Install.pm
# once (32µs+1µs) by Data::YAML::Writer::BEGIN@5 at line 5 of Data/YAML/Writer.pm
# once (31µs+1µs) by Sys::Hostname::BEGIN@5 at line 5 of Sys/Hostname.pm
# once (31µs+2µs) by Opcode::BEGIN@11 at line 11 of Opcode.pm
# once (30µs+2µs) by IO::Handle::BEGIN@264 at line 264 of IO/Handle.pm
# once (29µs+1µs) by Data::Dumper::BEGIN@22 at line 22 of Data/Dumper.pm
# once (28µs+1µs) by IO::Seekable::BEGIN@98 at line 98 of IO/Seekable.pm
# once (28µs+1µs) by IO::File::BEGIN@130 at line 130 of IO/File.pm
# once (27µs+1µs) by Text::Balanced::BEGIN@885 at line 885 of Text/Balanced.pm
# once (26µs+1µs) by FindBin::BEGIN@80 at line 80 of FindBin.pm
# once (26µs+900ns) by Benchmark::Perl::Formance::BEGIN@19 at line 19 of lib/Benchmark/Perl/Formance.pm
# once (26µs+900ns) by Data::OptList::BEGIN@10 at line 95 of Params/Util.pm
# once (25µs+900ns) by Devel::StackTrace::BEGIN@13 at line 13 of Devel/StackTrace.pm
# once (25µs+1µs) by Safe::BEGIN@29 at line 29 of Safe.pm
# once (25µs+1µs) by Class::XSAccessor::Heavy::BEGIN@7 at line 7 of Class/XSAccessor/Heavy.pm
# once (25µs+1000ns) by Safe::BEGIN@4 at line 4 of Safe.pm
# once (24µs+1µs) by IO::File::BEGIN@131 at line 131 of IO/File.pm
# once (24µs+1µs) by SelectSaver::BEGIN@38 at line 38 of SelectSaver.pm
# once (24µs+1µs) by Data::DPath::Path::BEGIN@13 at line 13 of Data/DPath/Path.pm
# once (24µs+1µs) by FindBin::BEGIN@84 at line 84 of FindBin.pm
# once (24µs+1µs) by IO::BEGIN@6 at line 6 of IO.pm
# once (24µs+0s) by Cwd::BEGIN@171 at line 171 of Cwd.pm
# once (24µs+0s) by Config::Perl::V::BEGIN@9 at line 9 of Config/Perl/V.pm
# once (22µs+1µs) by IO::Seekable::BEGIN@104 at line 104 of IO/Seekable.pm
# once (22µs+900ns) by SelectSaver::BEGIN@39 at line 39 of SelectSaver.pm
# once (22µs+800ns) by Exception::Class::BEGIN@11 at line 11 of Exception/Class.pm
# once (21µs+1µs) by IO::File::BEGIN@133 at line 133 of IO/File.pm
# once (20µs+900ns) by Benchmark::Perl::Formance::BEGIN@20 at line 20 of lib/Benchmark/Perl/Formance.pm
# once (20µs+900ns) by Text::Balanced::BEGIN@9 at line 9 of Text/Balanced.pm
# once (20µs+800ns) by Exception::Class::Base::BEGIN@11 at line 11 of Exception/Class/Base.pm
# once (19µs+700ns) by Class::XSAccessor::BEGIN@5 at line 5 of Class/XSAccessor.pm
# once (18µs+800ns) by Data::DPath::Context::BEGIN@13 at line 13 of Data/DPath/Context.pm
# once (18µs+600ns) by Sys::Info::BEGIN@5 at line 5 of Sys/Info.pm
# once (18µs+700ns) by Data::DPath::Filters::BEGIN@13 at line 13 of Data/DPath/Filters.pm
# once (18µs+500ns) by Sys::Info::Constants::BEGIN@5 at line 5 of Sys/Info/Constants.pm
# once (17µs+700ns) by Sys::Info::Base::BEGIN@6 at line 6 of Sys/Info/Base.pm
# once (15µs+0s) by Benchmark::Perl::Formance::BEGIN@9 at line 9 of lib/Benchmark/Perl/Formance.pm
# once (14µs+0s) by SelfLoader::BEGIN@4 at line 4 of SelfLoader.pm
# once (13µs+0s) by SelfLoader::BEGIN@42 at line 42 of SelfLoader.pm
# once (12µs+0s) by Benchmark::Perl::Formance::BEGIN@265 at line 265 of lib/Benchmark/Perl/Formance.pm
# once (12µs+0s) by Getopt::Long::BEGIN@25 at line 25 of Getopt/Long.pm
# once (10µs+0s) by Benchmark::Perl::Formance::BEGIN@10 at line 10 of lib/Benchmark/Perl/Formance.pm
# once (10µs+0s) by Data::DPath::Filters::BEGIN@14 at line 14 of Data/DPath/Filters.pm | ||||
29 | 68 | 28µs | my $pkg = shift; | ||
30 | 68 | 43µs | my $callpkg = caller($ExportLevel); | ||
31 | |||||
32 | 68 | 22µ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 | 68 | 97µ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 | 68 | 73µs | my $fail = ${$pkg . '::'}{EXPORT_FAIL} && \@{"$pkg\::EXPORT_FAIL"}; | ||
42 | 68 | 33µs | return export $pkg, $callpkg, @_ | ||
43 | if $Verbose or $Debug or $fail && @$fail > 1; | ||||
44 | 68 | 52µs | my $export_cache = ($Cache{$pkg} ||= {}); | ||
45 | 68 | 92µs | my $args = @_ or @_ = @$exports; | ||
46 | |||||
47 | 68 | 24µs | if ($args and not %$export_cache) { | ||
48 | s/^&//, $export_cache->{$_} = 1 | ||||
49 | 13 | 591µs | 308 | 63µs | foreach (@$exports, @{"$pkg\::EXPORT_OK"}); # spent 63µs making 308 calls to Exporter::CORE:subst, avg 204ns/call |
50 | } | ||||
51 | 68 | 8µ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 | 68 | 33µ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 | 45 | 409µs | 156 | 61µs | foreach (@_); # spent 61µs making 156 calls to Exporter::CORE:match, avg 390ns/call |
58 | } else { | ||||
59 | ($heavy = /\W/) and last | ||||
60 | 23 | 297µs | 193 | 40µs | foreach (@_); # spent 40µs making 193 calls to Exporter::CORE:match, avg 206ns/call |
61 | } | ||||
62 | 68 | 71µs | 6 | 1.33ms | return export $pkg, $callpkg, ($args ? @_ : ()) if $heavy; # spent 1.33ms making 6 calls to Exporter::export, avg 222µs/call |
63 | local $SIG{__WARN__} = | ||||
64 | 62 | 211µs | sub {require Carp; &Carp::carp} if not $SIG{__WARN__}; | ||
65 | # shortcut for the common case of no type character | ||||
66 | 62 | 835µ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 18µs (6+12) within Exporter::export_to_level which was called:
# once (6µs+12µs) by Time::HiRes::import at line 63 of Time/HiRes.pm | ||||
81 | 1 | 7µs | 2 | 142µs | goto &{as_heavy()}; # spent 129µs making 1 call to Exporter::Heavy::heavy_export_to_level
# spent 12µs making 1 call to Exporter::as_heavy |
82 | } | ||||
83 | |||||
84 | sub export_tags { | ||||
85 | goto &{as_heavy()}; | ||||
86 | } | ||||
87 | |||||
88 | # spent 20µs (6+14) within Exporter::export_ok_tags which was called:
# once (6µs+14µs) by Data::DPath::Path::BEGIN@17 at line 31 of Text/Balanced.pm | ||||
89 | 1 | 7µs | 2 | 33µs | goto &{as_heavy()}; # spent 19µs making 1 call to Exporter::Heavy::heavy_export_ok_tags
# spent 14µs making 1 call to Exporter::as_heavy |
90 | } | ||||
91 | |||||
92 | sub require_version { | ||||
93 | goto &{as_heavy()}; | ||||
94 | } | ||||
95 | |||||
96 | 1 | 4µs | 1; | ||
97 | __END__ | ||||
sub Exporter::CORE:match; # opcode | |||||
sub Exporter::CORE:subst; # opcode |