Filename | /home/hinrik/perl5/perlbrew/perls/perl-5.13.5/lib/5.13.5/Exporter.pm |
Statements | Executed 876 statements in 4.58ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
50 | 50 | 28 | 3.12ms | 6.02ms | import | Exporter::
18 | 2 | 1 | 1.63ms | 1.79ms | as_heavy | Exporter::
17 | 1 | 1 | 539µs | 803µs | export | Exporter::
267 | 2 | 1 | 324µs | 324µs | CORE:subst (opcode) | Exporter::
55 | 2 | 1 | 102µs | 102µs | CORE:match (opcode) | Exporter::
1 | 1 | 1 | 10µs | 1.53ms | export_ok_tags | Exporter::
0 | 0 | 0 | 0s | 0s | __ANON__[:65] | 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 | 16µs | require 5.006; | ||
4 | |||||
5 | # Be lean. | ||||
6 | #use strict; | ||||
7 | #no strict 'refs'; | ||||
8 | |||||
9 | 1 | 1µs | our $Debug = 0; | ||
10 | 1 | 1µs | our $ExportLevel = 0; | ||
11 | 1 | 700ns | our $Verbose ||= 0; | ||
12 | 1 | 1µs | our $VERSION = '5.64_03'; | ||
13 | 1 | 1µs | our (%Cache); | ||
14 | |||||
15 | sub as_heavy { | ||||
16 | 18 | 164µ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 | 18 | 59µs | my $c = (caller(1))[3]; | ||
20 | 18 | 132µs | 18 | 56µs | $c =~ s/.*:://; # spent 56µs making 18 calls to Exporter::CORE:subst, avg 3µs/call |
21 | 18 | 89µs | \&{"Exporter::Heavy::heavy_$c"}; | ||
22 | } | ||||
23 | |||||
24 | # spent 803µs (539+264) within Exporter::export which was called 17 times, avg 47µs/call:
# 17 times (539µs+264µs) by Exporter::import at line 63, avg 47µs/call | ||||
25 | 17 | 144µs | 34 | 2.00ms | goto &{as_heavy()}; # spent 1.73ms making 17 calls to Exporter::Heavy::heavy_export, avg 102µs/call
# spent 264µs making 17 calls to Exporter::as_heavy, avg 16µs/call |
26 | } | ||||
27 | |||||
28 | # spent 6.02ms (3.12+2.91) within Exporter::import which was called 50 times, avg 120µs/call:
# once (178µs+590µs) by Regexp::Common::URI::RFC2806::BEGIN@4 at line 4 of Regexp/Common/URI/RFC2806.pm
# once (193µs+158µs) by Regexp::Common::URI::file::BEGIN@5 at line 5 of Regexp/Common/URI/file.pm
# once (178µs+140µs) by Regexp::Common::URI::fax::BEGIN@5 at line 5 of Regexp/Common/URI/fax.pm
# once (159µs+142µs) by Regexp::Common::URI::gopher::BEGIN@6 at line 6 of Regexp/Common/URI/gopher.pm
# once (188µs+38µs) by Hailo::Engine::Default::BEGIN@12 at line 12 of Hailo/Engine/Default.pm
# once (37µs+185µs) by Regexp::Common::URI::prospero::BEGIN@5 at line 5 of Regexp/Common/URI/prospero.pm
# once (32µs+168µs) by Regexp::Common::URI::news::BEGIN@5 at line 5 of Regexp/Common/URI/news.pm
# once (32µs+163µs) by Regexp::Common::URI::wais::BEGIN@5 at line 5 of Regexp/Common/URI/wais.pm
# once (82µs+113µs) by Regexp::Common::URI::pop::BEGIN@6 at line 6 of Regexp/Common/URI/pop.pm
# once (73µs+119µs) by Regexp::Common::URI::RFC2806::BEGIN@3 at line 3 of Regexp/Common/URI/RFC2806.pm
# once (35µs+158µs) by Regexp::Common::URI::ftp::BEGIN@5 at line 5 of Regexp/Common/URI/ftp.pm
# once (32µs+147µs) by Regexp::Common::URI::telnet::BEGIN@5 at line 5 of Regexp/Common/URI/telnet.pm
# once (33µs+142µs) by Regexp::Common::URI::gopher::BEGIN@5 at line 5 of Regexp/Common/URI/gopher.pm
# once (33µs+139µs) by Regexp::Common::URI::http::BEGIN@5 at line 5 of Regexp/Common/URI/http.pm
# once (31µs+124µs) by Regexp::Common::URI::RFC2384::BEGIN@5 at line 5 of Regexp/Common/URI/RFC2384.pm
# once (32µs+103µs) by Regexp::Common::URI::tel::BEGIN@5 at line 5 of Regexp/Common/URI/tel.pm
# once (31µs+96µs) by Regexp::Common::URI::pop::BEGIN@5 at line 5 of Regexp/Common/URI/pop.pm
# once (105µs+16µs) by Tie::RefHash::BEGIN@106 at line 111 of Tie/RefHash.pm
# once (31µs+81µs) by Regexp::Common::URI::tv::BEGIN@8 at line 8 of Regexp/Common/URI/tv.pm
# once (94µs+3µs) by Mouse::BEGIN@8 at line 8 of Mouse.pm
# once (86µs+5µs) by Hailo::Engine::Default::BEGIN@11 at line 11 of Hailo/Engine/Default.pm
# once (74µs+11µs) by Hailo::BEGIN@14 at line 14 of Hailo.pm
# once (68µs+8µs) by Tie::RefHash::BEGIN@94 at line 94 of Tie/RefHash.pm
# once (70µs+4µs) by Regexp::Common::URI::fax::BEGIN@4 at line 4 of Regexp/Common/URI/fax.pm
# once (67µs+5µs) by Fatal::BEGIN@4 at line 4 of Fatal.pm
# once (67µs+5µs) by Sub::Install::BEGIN@6 at line 6 of Sub/Install.pm
# once (60µs+6µs) by namespace::clean::BEGIN@15 at line 15 of namespace/clean.pm
# once (59µs+5µs) by namespace::clean::BEGIN@14 at line 14 of namespace/clean.pm
# once (59µs+4µs) by Tie::Hash::BEGIN@188 at line 188 of Tie/Hash.pm
# once (53µs+2µs) by Mouse::Role::BEGIN@6 at line 6 of Mouse/Role.pm
# once (51µs+1µs) by Hailo::BEGIN@13 at line 13 of Hailo.pm
# once (47µs+2µs) by Hailo::Tokenizer::Words::BEGIN@14 at line 14 of Hailo/Tokenizer/Words.pm
# once (46µs+2µs) by Regexp::Common::URI::prospero::BEGIN@4 at line 4 of Regexp/Common/URI/prospero.pm
# once (48µs+0s) by Hailo::Storage::BEGIN@12 at line 12 of Hailo/Storage.pm
# once (44µs+2µs) by Package::Stash::BEGIN@9 at line 9 of Package/Stash.pm
# once (44µs+2µs) by Regexp::Common::URI::tv::BEGIN@7 at line 7 of Regexp/Common/URI/tv.pm
# once (44µs+2µs) by Regexp::Common::URI::ftp::BEGIN@4 at line 4 of Regexp/Common/URI/ftp.pm
# once (44µs+2µs) by Regexp::Common::URI::gopher::BEGIN@4 at line 4 of Regexp/Common/URI/gopher.pm
# once (42µs+2µs) by Regexp::Common::URI::file::BEGIN@4 at line 4 of Regexp/Common/URI/file.pm
# once (42µs+2µs) by Regexp::Common::URI::http::BEGIN@4 at line 4 of Regexp/Common/URI/http.pm
# once (42µs+1µs) by Regexp::Common::URI::telnet::BEGIN@4 at line 4 of Regexp/Common/URI/telnet.pm
# once (41µs+2µs) by Regexp::Common::URI::pop::BEGIN@4 at line 4 of Regexp/Common/URI/pop.pm
# once (41µs+1µs) by Regexp::Common::URI::wais::BEGIN@4 at line 4 of Regexp/Common/URI/wais.pm
# once (41µs+2µs) by Regexp::Common::URI::news::BEGIN@4 at line 4 of Regexp/Common/URI/news.pm
# once (41µs+2µs) by Regexp::Common::URI::tel::BEGIN@4 at line 4 of Regexp/Common/URI/tel.pm
# once (41µs+2µs) by Package::Stash::BEGIN@10 at line 10 of Package/Stash.pm
# once (40µs+2µs) by Mouse::BEGIN@9 at line 9 of Mouse.pm
# once (40µs+2µs) by Mouse::Role::BEGIN@7 at line 7 of Mouse/Role.pm
# once (33µs+0s) by Sub::Identify::BEGIN@4 at line 4 of Sub/Identify.pm
# once (33µs+0s) by B::Hooks::EndOfScope::BEGIN@14 at line 14 of B/Hooks/EndOfScope.pm | ||||
29 | 50 | 73µs | my $pkg = shift; | ||
30 | 50 | 76µs | my $callpkg = caller($ExportLevel); | ||
31 | |||||
32 | 50 | 62µ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 | 50 | 139µ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 | 50 | 116µs | my $fail = ${$pkg . '::'}{EXPORT_FAIL} && \@{"$pkg\::EXPORT_FAIL"}; | ||
42 | 50 | 75µs | return export $pkg, $callpkg, @_ | ||
43 | if $Verbose or $Debug or $fail && @$fail > 1; | ||||
44 | 50 | 85µs | my $export_cache = ($Cache{$pkg} ||= {}); | ||
45 | 50 | 72µs | my $args = @_ or @_ = @$exports; | ||
46 | |||||
47 | 50 | 52µs | local $_; | ||
48 | 50 | 112µs | if ($args and not %$export_cache) { | ||
49 | s/^&//, $export_cache->{$_} = 1 | ||||
50 | 13 | 1.20ms | 249 | 267µs | foreach (@$exports, @{"$pkg\::EXPORT_OK"}); # spent 267µs making 249 calls to Exporter::CORE:subst, avg 1µs/call |
51 | } | ||||
52 | 50 | 49µs | my $heavy; | ||
53 | # Try very hard not to use {} and hence have to enter scope on the foreach | ||||
54 | # We bomb out of the loop with last as soon as heavy is set. | ||||
55 | 50 | 107µs | if ($args or $fail) { | ||
56 | ($heavy = (/\W/ or $args and not exists $export_cache->{$_} | ||||
57 | or $fail and @$fail and $_ eq $fail->[0])) and last | ||||
58 | 46 | 460µs | 54 | 100µs | foreach (@_); # spent 100µs making 54 calls to Exporter::CORE:match, avg 2µs/call |
59 | } else { | ||||
60 | ($heavy = /\W/) and last | ||||
61 | 4 | 18µs | 1 | 2µs | foreach (@_); # spent 2µs making 1 call to Exporter::CORE:match |
62 | } | ||||
63 | 50 | 596µs | 17 | 803µs | return export $pkg, $callpkg, ($args ? @_ : ()) if $heavy; # spent 803µs making 17 calls to Exporter::export, avg 47µs/call |
64 | local $SIG{__WARN__} = | ||||
65 | 33 | 173µs | sub {require Carp; &Carp::carp} if not $SIG{__WARN__}; | ||
66 | # shortcut for the common case of no type character | ||||
67 | 33 | 491µs | *{"$callpkg\::$_"} = \&{"$pkg\::$_"} foreach @_; | ||
68 | } | ||||
69 | |||||
70 | # Default methods | ||||
71 | |||||
72 | sub export_fail { | ||||
73 | my $self = shift; | ||||
74 | @_; | ||||
75 | } | ||||
76 | |||||
77 | # Unfortunately, caller(1)[3] "does not work" if the caller is aliased as | ||||
78 | # *name = \&foo. Thus the need to create a lot of identical subroutines | ||||
79 | # Otherwise we could have aliased them to export(). | ||||
80 | |||||
81 | sub export_to_level { | ||||
82 | goto &{as_heavy()}; | ||||
83 | } | ||||
84 | |||||
85 | sub export_tags { | ||||
86 | goto &{as_heavy()}; | ||||
87 | } | ||||
88 | |||||
89 | # spent 1.53ms (10µs+1.53) within Exporter::export_ok_tags which was called:
# once (10µs+1.53ms) by DBI::BEGIN@163 at line 266 of DBI.pm | ||||
90 | 1 | 12µs | 2 | 1.57ms | goto &{as_heavy()}; # spent 1.53ms making 1 call to Exporter::as_heavy
# spent 46µs making 1 call to Exporter::Heavy::heavy_export_ok_tags |
91 | } | ||||
92 | |||||
93 | sub require_version { | ||||
94 | goto &{as_heavy()}; | ||||
95 | } | ||||
96 | |||||
97 | 1 | 4µs | 1; | ||
98 | __END__ | ||||
sub Exporter::CORE:match; # opcode | |||||
sub Exporter::CORE:subst; # opcode |