Filename | /home/ss5/perl5/perlbrew/perls/perl-5.14.1/lib/5.14.1/Exporter.pm |
Statements | Executed 580 statements in 11.0ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
37 | 37 | 23 | 8.87ms | 30.2ms | import | Exporter::
3 | 2 | 1 | 6.59ms | 6.91ms | as_heavy | Exporter::
239 | 2 | 1 | 558µs | 558µs | CORE:match (opcode) | Exporter::
233 | 2 | 1 | 345µs | 345µs | CORE:subst (opcode) | Exporter::
2 | 1 | 1 | 49µs | 6.90ms | export | Exporter::
1 | 1 | 1 | 24µs | 86µ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 | 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 | 57µ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 | 1µs | our $ExportLevel = 0; | ||
11 | 1 | 2µs | our $Verbose ||= 0; | ||
12 | 1 | 2µs | our $VERSION = '5.66'; | ||
13 | 1 | 1µs | our (%Cache); | ||
14 | |||||
15 | sub as_heavy { | ||||
16 | 3 | 438µ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 | 40µs | my $c = (caller(1))[3]; | ||
20 | 3 | 92µs | 3 | 56µs | $c =~ s/.*:://; # spent 56µs making 3 calls to Exporter::CORE:subst, avg 19µs/call |
21 | 3 | 63µs | \&{"Exporter::Heavy::heavy_$c"}; | ||
22 | } | ||||
23 | |||||
24 | # spent 6.90ms (49µs+6.85) within Exporter::export which was called 2 times, avg 3.45ms/call:
# 2 times (49µs+6.85ms) by Exporter::import at line 62, avg 3.45ms/call | ||||
25 | 2 | 54µs | 4 | 20.5ms | goto &{as_heavy()}; # spent 13.6ms making 2 calls to Exporter::Heavy::heavy_export, avg 6.81ms/call
# spent 6.85ms making 2 calls to Exporter::as_heavy, avg 3.42ms/call |
26 | } | ||||
27 | |||||
28 | # spent 30.2ms (8.87+21.4) within Exporter::import which was called 37 times, avg 817µs/call:
# once (872µs+19.9ms) by POSIX::import at line 29 of POSIX.pm
# once (1.76ms+217µs) by POSIX::BEGIN@13 at line 13 of POSIX.pm
# once (228µs+830µs) by Safe::BEGIN@46 at line 46 of Safe.pm
# once (406µs+46µs) by Data::DPath::Context::BEGIN@16 at line 16 of Data/DPath/Context.pm
# once (331µs+23µs) by Data::DPath::Context::BEGIN@19 at line 19 of Data/DPath/Context.pm
# once (260µs+46µs) by Data::DPath::Path::BEGIN@17 at line 17 of Data/DPath/Path.pm
# once (254µs+25µs) by Data::DPath::Context::BEGIN@17 at line 17 of Data/DPath/Context.pm
# once (253µs+10µs) by Devel::StackTrace::BEGIN@13 at line 13 of Devel/StackTrace.pm
# once (246µs+13µs) by IO::Handle::BEGIN@263 at line 263 of IO/Handle.pm
# once (238µs+20µs) by Class::XSAccessor::Array::BEGIN@5 at line 5 of Class/XSAccessor/Array.pm
# once (215µs+12µs) by Text::Balanced::BEGIN@343 at line 343 of Text/Balanced.pm
# once (206µs+8µs) by SelectSaver::BEGIN@38 at line 38 of SelectSaver.pm
# once (200µs+13µs) by IO::Handle::BEGIN@264 at line 264 of IO/Handle.pm
# once (197µs+13µs) by Attribute::Handlers::BEGIN@3 at line 3 of Attribute/Handlers.pm
# once (191µs+12µs) by Text::Balanced::BEGIN@885 at line 885 of Text/Balanced.pm
# once (184µs+13µs) by Opcode::BEGIN@11 at line 11 of Opcode.pm
# once (185µs+12µs) by Data::Dumper::BEGIN@20 at line 20 of Data/Dumper.pm
# once (179µs+16µs) by Data::DPath::Context::BEGIN@20 at line 20 of Data/DPath/Context.pm
# once (179µs+11µs) by Sub::Install::BEGIN@6 at line 6 of Sub/Install.pm
# once (180µs+9µs) by Tie::Hash::BEGIN@188 at line 188 of Tie/Hash.pm
# once (161µs+10µs) by Safe::BEGIN@4 at line 4 of Safe.pm
# once (148µs+8µs) by IO::BEGIN@6 at line 6 of IO.pm
# once (141µs+8µs) by Data::OptList::BEGIN@10 at line 95 of Params/Util.pm
# once (142µs+7µs) by Safe::BEGIN@29 at line 29 of Safe.pm
# once (140µs+8µs) by Exception::Class::BEGIN@11 at line 11 of Exception/Class.pm
# once (138µs+7µs) by Class::XSAccessor::Heavy::BEGIN@7 at line 7 of Class/XSAccessor/Heavy.pm
# once (137µs+8µs) by Data::DPath::Path::BEGIN@13 at line 13 of Data/DPath/Path.pm
# once (133µs+10µs) by Text::Balanced::BEGIN@9 at line 9 of Text/Balanced.pm
# once (133µs+9µs) by Exception::Class::Base::BEGIN@11 at line 11 of Exception/Class/Base.pm
# once (129µs+6µs) by SelectSaver::BEGIN@39 at line 39 of SelectSaver.pm
# once (126µs+7µs) by Data::DPath::Context::BEGIN@13 at line 13 of Data/DPath/Context.pm
# once (119µs+9µs) by main::BEGIN@11 at line 11 of bin/dpath
# once (107µs+5µs) by Data::DPath::Filters::BEGIN@13 at line 13 of Data/DPath/Filters.pm
# once (100µs+5µs) by Class::XSAccessor::BEGIN@5 at line 5 of Class/XSAccessor.pm
# once (101µs+0s) by SelfLoader::BEGIN@42 at line 42 of SelfLoader.pm
# once (98µs+0s) by SelfLoader::BEGIN@4 at line 4 of SelfLoader.pm
# once (60µs+0s) by Data::DPath::Filters::BEGIN@14 at line 14 of Data/DPath/Filters.pm | ||||
29 | 37 | 100µs | my $pkg = shift; | ||
30 | 37 | 126µs | my $callpkg = caller($ExportLevel); | ||
31 | |||||
32 | 37 | 79µ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 | 37 | 333µ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 | 37 | 359µs | my $fail = ${$pkg . '::'}{EXPORT_FAIL} && \@{"$pkg\::EXPORT_FAIL"}; | ||
42 | 37 | 180µs | return export $pkg, $callpkg, @_ | ||
43 | if $Verbose or $Debug or $fail && @$fail > 1; | ||||
44 | 37 | 165µs | my $export_cache = ($Cache{$pkg} ||= {}); | ||
45 | 37 | 371µs | my $args = @_ or @_ = @$exports; | ||
46 | |||||
47 | 37 | 61µs | if ($args and not %$export_cache) { | ||
48 | s/^&//, $export_cache->{$_} = 1 | ||||
49 | 7 | 2.24ms | 230 | 289µs | foreach (@$exports, @{"$pkg\::EXPORT_OK"}); # spent 289µs making 230 calls to Exporter::CORE:subst, avg 1µs/call |
50 | } | ||||
51 | 37 | 21µ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 | 37 | 109µ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 | 27 | 1.47ms | 95 | 305µs | foreach (@_); # spent 305µs making 95 calls to Exporter::CORE:match, avg 3µs/call |
58 | } else { | ||||
59 | ($heavy = /\W/) and last | ||||
60 | 10 | 1.15ms | 144 | 253µs | foreach (@_); # spent 253µs making 144 calls to Exporter::CORE:match, avg 2µs/call |
61 | } | ||||
62 | 37 | 206µs | 2 | 6.90ms | return export $pkg, $callpkg, ($args ? @_ : ()) if $heavy; # spent 6.90ms making 2 calls to Exporter::export, avg 3.45ms/call |
63 | local $SIG{__WARN__} = | ||||
64 | 35 | 825µs | sub {require Carp; &Carp::carp} if not $SIG{__WARN__}; | ||
65 | # shortcut for the common case of no type character | ||||
66 | 35 | 2.42ms | *{"$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 | # spent 86µs (24+61) within Exporter::export_ok_tags which was called:
# once (24µs+61µs) by Data::DPath::Path::BEGIN@17 at line 31 of Text/Balanced.pm | ||||
89 | 1 | 28µs | 2 | 160µs | goto &{as_heavy()}; # spent 99µs making 1 call to Exporter::Heavy::heavy_export_ok_tags
# spent 61µs making 1 call to Exporter::as_heavy |
90 | } | ||||
91 | |||||
92 | sub require_version { | ||||
93 | goto &{as_heavy()}; | ||||
94 | } | ||||
95 | |||||
96 | 1 | 19µs | 1; | ||
97 | __END__ | ||||
sub Exporter::CORE:match; # opcode | |||||
sub Exporter::CORE:subst; # opcode |