Filename | /usr/share/perl/5.14/Exporter.pm |
Statements | Executed 2187 statements in 12.9ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
79 | 56 | 37 | 10.1ms | 25.4ms | import | Exporter::
30 | 2 | 1 | 3.34ms | 3.69ms | as_heavy | Exporter::
405 | 2 | 1 | 735µs | 735µs | CORE:subst (opcode) | Exporter::
296 | 2 | 1 | 573µs | 573µs | CORE:match (opcode) | Exporter::
28 | 1 | 1 | 420µs | 1.29ms | export | Exporter::
2 | 2 | 2 | 36µs | 2.85ms | export_tags | Exporter::
0 | 0 | 0 | 0s | 0s | __ANON__[:65] | Exporter::
0 | 0 | 0 | 0s | 0s | export_fail | Exporter::
0 | 0 | 0 | 0s | 0s | export_ok_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 | 20µ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.64_03'; | ||
13 | 1 | 1µs | our (%Cache); | ||
14 | |||||
15 | sub as_heavy { | ||||
16 | 30 | 236µ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 | 30 | 213µs | my $c = (caller(1))[3]; | ||
20 | 30 | 377µs | 30 | 185µs | $c =~ s/.*:://; # spent 185µs making 30 calls to Exporter::CORE:subst, avg 6µs/call |
21 | 60 | 363µs | \&{"Exporter::Heavy::heavy_$c"}; | ||
22 | } | ||||
23 | |||||
24 | # spent 1.29ms (420µs+874µs) within Exporter::export which was called 28 times, avg 46µs/call:
# 28 times (420µs+874µs) by Exporter::import at line 63, avg 46µs/call | ||||
25 | 56 | 493µs | 56 | 13.7ms | goto &{as_heavy()}; # spent 12.9ms making 28 calls to Exporter::Heavy::heavy_export, avg 460µs/call
# spent 874µs making 28 calls to Exporter::as_heavy, avg 31µs/call |
26 | } | ||||
27 | |||||
28 | # spent 25.4ms (10.1+15.3) within Exporter::import which was called 79 times, avg 321µs/call:
# 24 times (1.72ms+7.67ms) by Error::import at line 63 of Error.pm, avg 391µs/call
# once (55µs+2.69ms) by CGI::Session::Driver::file::BEGIN@9 at line 9 of /usr/local/src/github.com/foswiki/core/lib/CPAN/lib/CGI/Session/Driver/file.pm
# once (54µs+1.78ms) by Foswiki::Store::VC::Handler::BEGIN@34 at line 34 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/Store/VC/Handler.pm
# once (51µs+1.66ms) by Foswiki::Users::HtPasswdUser::BEGIN@23 at line 23 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/Users/HtPasswdUser.pm
# once (967µs+89µs) by File::Temp::BEGIN@146 at line 146 of File/Temp.pm
# once (899µs+93µs) by Digest::SHA::BEGIN@7 at line 7 of Digest/SHA.pm
# once (711µs+195µs) by IO::Seekable::BEGIN@12 at line 12 of IO/Seekable.pm
# once (667µs+231µs) by Foswiki::Meta::BEGIN@119 at line 119 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/Meta.pm
# once (131µs+543µs) by Safe::BEGIN@46 at line 46 of Safe.pm
# once (455µs+44µs) by Foswiki::Request::BEGIN@37 at line 26 of IO/File.pm
# once (208µs+24µs) by CGI::BEGIN@28 at line 28 of CGI.pm
# once (176µs+25µs) by CGI::Carp::import at line 371 of CGI/Carp.pm
# once (161µs+31µs) by Foswiki::Sandbox::BEGIN@39 at line 39 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/Sandbox.pm
# once (153µs+21µs) by Foswiki::Serialise::BEGIN@95 at line 95 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/Serialise.pm
# once (157µs+6µs) by Time::Local::BEGIN@4 at line 4 of Time/Local.pm
# once (131µs+6µs) by IO::Seekable::BEGIN@6 at line 6 of IO/Seekable.pm
# once (113µs+15µs) by Foswiki::BEGIN@28 at line 28 of setlib.cfg
# once (114µs+13µs) by CGI::BEGIN@3 at line 3 of CGI.pm
# once (114µs+6µs) by CGI::Session::Driver::file::BEGIN@7 at line 7 of /usr/local/src/github.com/foswiki/core/lib/CPAN/lib/CGI/Session/Driver/file.pm
# once (113µs+6µs) by Data::Dumper::BEGIN@20 at line 20 of Data/Dumper.pm
# once (105µs+7µs) by CGI::Session::Driver::BEGIN@8 at line 8 of /usr/local/src/github.com/foswiki/core/lib/CPAN/lib/CGI/Session/Driver.pm
# once (103µs+6µs) by SelectSaver::BEGIN@7 at line 7 of SelectSaver.pm
# once (102µs+7µs) by IO::File::BEGIN@9 at line 9 of IO/File.pm
# once (99µs+10µs) by File::Temp::BEGIN@145 at line 145 of File/Temp.pm
# once (104µs+6µs) by File::Temp::BEGIN@143 at line 143 of File/Temp.pm
# once (102µs+7µs) by Opcode::BEGIN@11 at line 11 of Opcode.pm
# once (99µs+6µs) by IO::File::BEGIN@8 at line 8 of IO/File.pm
# once (98µs+6µs) by IO::Handle::BEGIN@7 at line 7 of IO/Handle.pm
# once (99µs+5µs) by CGI::Session::BEGIN@6 at line 6 of /usr/local/src/github.com/foswiki/core/lib/CPAN/lib/CGI/Session.pm
# once (98µs+6µs) by CGI::Cookie::BEGIN@21 at line 21 of CGI/Cookie.pm
# once (96µs+5µs) by IO::Handle::BEGIN@6 at line 6 of IO/Handle.pm
# once (94µs+5µs) by CGI::Session::Serialize::default::BEGIN@9 at line 9 of /usr/local/src/github.com/foswiki/core/lib/CPAN/lib/CGI/Session/Serialize/default.pm
# once (95µs+3µs) by Foswiki::Store::Interfaces::QueryAlgorithm::BEGIN@342 at line 342 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/Store/Interfaces/QueryAlgorithm.pm
# once (94µs+3µs) by Sort::Maker::BEGIN@6 at line 6 of /usr/local/src/github.com/foswiki/core/lib/CPAN/lib/Sort/Maker.pm
# once (91µs+5µs) by SelectSaver::BEGIN@6 at line 6 of SelectSaver.pm
# once (90µs+5µs) by Safe::BEGIN@29 at line 29 of Safe.pm
# once (90µs+6µs) by Carp::BEGIN@4.1 at line 4 of Carp/Heavy.pm
# once (89µs+5µs) by File::Temp::BEGIN@147 at line 147 of File/Temp.pm
# once (89µs+5µs) by IO::BEGIN@6 at line 6 of IO.pm
# once (84µs+4µs) by Foswiki::Users::HtPasswdUser::BEGIN@2.2 at line 2 of (eval 46)[/usr/local/src/github.com/foswiki/core/lib/Foswiki/Users/HtPasswdUser.pm:50]
# once (83µs+5µs) by IO::File::BEGIN@11 at line 11 of IO/File.pm
# once (83µs+4µs) by Safe::BEGIN@5 at line 5 of Safe.pm
# once (80µs+5µs) by Foswiki::Meta::BEGIN@546 at line 546 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/Meta.pm
# once (73µs+4µs) by File::Temp::Dir::BEGIN@2405 at line 2405 of File/Temp.pm
# once (75µs+0s) by Assert::BEGIN@20 at line 20 of /usr/local/src/github.com/foswiki/core/lib/Assert.pm
# once (70µs+3µs) by Foswiki::Templates::BEGIN@483 at line 483 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/Templates.pm
# once (70µs+3µs) by CGI::Session::Serialize::default::BEGIN@7 at line 7 of /usr/local/src/github.com/foswiki/core/lib/CPAN/lib/CGI/Session/Serialize/default.pm
# once (66µs+0s) by CGI::Carp::BEGIN@333 at line 333 of CGI/Carp.pm
# once (62µs+2µs) by CGI::Session::Serialize::default::BEGIN@10 at line 10 of /usr/local/src/github.com/foswiki/core/lib/CPAN/lib/CGI/Session/Serialize/default.pm
# once (61µs+2µs) by File::Path::BEGIN@6 at line 6 of File/Path.pm
# once (59µs+2µs) by Foswiki::Request::BEGIN@38 at line 38 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/Request.pm
# once (48µs+0s) by Foswiki::Users::HtPasswdUser::BEGIN@2 at line 2 of (eval 45)[/usr/local/src/github.com/foswiki/core/lib/Foswiki/Users/HtPasswdUser.pm:48]
# once (43µs+0s) by Crypt::PasswdMD5::BEGIN@65 at line 65 of Crypt/PasswdMD5.pm
# once (41µs+0s) by Cwd::BEGIN@171 at line 171 of Cwd.pm
# once (40µs+0s) by CGI::Session::ID::md5::BEGIN@6 at line 6 of /usr/local/src/github.com/foswiki/core/lib/CPAN/lib/CGI/Session/ID/md5.pm
# once (38µs+0s) by File::Temp::BEGIN@148 at line 148 of File/Temp.pm | ||||
29 | 79 | 151µs | my $pkg = shift; | ||
30 | 79 | 168µs | my $callpkg = caller($ExportLevel); | ||
31 | |||||
32 | 79 | 142µ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 | 158 | 562µ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 | 204 | 623µs | my $fail = ${$pkg . '::'}{EXPORT_FAIL} && \@{"$pkg\::EXPORT_FAIL"}; | ||
42 | 79 | 167µs | return export $pkg, $callpkg, @_ | ||
43 | if $Verbose or $Debug or $fail && @$fail > 1; | ||||
44 | 79 | 182µs | my $export_cache = ($Cache{$pkg} ||= {}); | ||
45 | 79 | 220µs | my $args = @_ or @_ = @$exports; | ||
46 | |||||
47 | 79 | 130µs | local $_; | ||
48 | 79 | 145µs | if ($args and not %$export_cache) { | ||
49 | 11 | 19µs | s/^&//, $export_cache->{$_} = 1 | ||
50 | 11 | 2.26ms | 375 | 550µs | foreach (@$exports, @{"$pkg\::EXPORT_OK"}); # spent 550µs making 375 calls to Exporter::CORE:subst, avg 1µs/call |
51 | } | ||||
52 | 79 | 92µ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 | 79 | 227µ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 | 61 | 1.71ms | 204 | 437µs | foreach (@_); # spent 437µs making 204 calls to Exporter::CORE:match, avg 2µs/call |
59 | } else { | ||||
60 | ($heavy = /\W/) and last | ||||
61 | 18 | 606µs | 92 | 136µs | foreach (@_); # spent 136µs making 92 calls to Exporter::CORE:match, avg 1µs/call |
62 | } | ||||
63 | 79 | 404µs | 28 | 1.29ms | return export $pkg, $callpkg, ($args ? @_ : ()) if $heavy; # spent 1.29ms making 28 calls to Exporter::export, avg 46µs/call |
64 | local $SIG{__WARN__} = | ||||
65 | 51 | 152µs | sub {require Carp; &Carp::carp} if not $SIG{__WARN__}; | ||
66 | # shortcut for the common case of no type character | ||||
67 | 587 | 3.21ms | *{"$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 | # spent 2.85ms (36µs+2.81) within Exporter::export_tags which was called 2 times, avg 1.43ms/call:
# once (21µs+2.78ms) by Foswiki::BEGIN@46 at line 31 of /usr/local/src/github.com/foswiki/core/lib/Assert.pm
# once (14µs+33µs) by Foswiki::Sandbox::BEGIN@39 at line 202 of File/Temp.pm | ||||
86 | 4 | 45µs | 4 | 2.93ms | goto &{as_heavy()}; # spent 2.81ms making 2 calls to Exporter::as_heavy, avg 1.41ms/call
# spent 118µs making 2 calls to Exporter::Heavy::heavy_export_tags, avg 59µs/call |
87 | } | ||||
88 | |||||
89 | sub export_ok_tags { | ||||
90 | goto &{as_heavy()}; | ||||
91 | } | ||||
92 | |||||
93 | sub require_version { | ||||
94 | goto &{as_heavy()}; | ||||
95 | } | ||||
96 | |||||
97 | 1 | 8µs | 1; | ||
98 | __END__ | ||||
sub Exporter::CORE:match; # opcode | |||||
sub Exporter::CORE:subst; # opcode |