Filename | /usr/share/perl/5.10/Exporter.pm |
Statements | Executed 875 statements in 7.15ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
47 | 47 | 27 | 5.68ms | 14.0ms | import | Exporter::
13 | 2 | 1 | 2.41ms | 2.58ms | as_heavy | Exporter::
340 | 1 | 1 | 441µs | 441µs | CORE:match (opcode) | Exporter::
270 | 2 | 1 | 326µs | 326µs | CORE:subst (opcode) | Exporter::
10 | 4 | 3 | 82µs | 261µs | export | Exporter::
3 | 1 | 1 | 26µs | 2.42ms | export_to_level | 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_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 | 23µ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 | 2µs | our $Verbose ||= 0; | ||
12 | 1 | 1µs | our $VERSION = '5.63'; | ||
13 | 1 | 2µs | our (%Cache); | ||
14 | |||||
15 | # Carp 1.05+ does this now for us, but we may be running with an old Carp | ||||
16 | 1 | 2µs | $Carp::Internal{Exporter}++; | ||
17 | |||||
18 | sub as_heavy { | ||||
19 | 52 | 425µs | require Exporter::Heavy; | ||
20 | # Unfortunately, this does not work if the caller is aliased as *name = \&foo | ||||
21 | # Thus the need to create a lot of identical subroutines | ||||
22 | my $c = (caller(1))[3]; | ||||
23 | 13 | 47µs | $c =~ s/.*:://; # spent 47µs making 13 calls to Exporter::CORE:subst, avg 4µs/call | ||
24 | \&{"Exporter::Heavy::heavy_$c"}; | ||||
25 | } | ||||
26 | |||||
27 | # spent 261µs (82+179) within Exporter::export which was called 10 times, avg 26µs/call:
# 5 times (43µs+96µs) by Exporter::import at line 63, avg 28µs/call
# 3 times (22µs+47µs) by Exporter::Heavy::heavy_export_to_level at line 203 of Exporter/Heavy.pm, avg 23µs/call
# once (9µs+18µs) by FileHandle::import at line 81 of FileHandle.pm
# once (8µs+18µs) by FileHandle::import at line 73 of FileHandle.pm | ||||
28 | 10 | 98µs | 20 | 9.89ms | goto &{as_heavy()}; # spent 9.71ms making 10 calls to Exporter::Heavy::heavy_export, avg 971µs/call
# spent 179µs making 10 calls to Exporter::as_heavy, avg 18µs/call |
29 | } | ||||
30 | |||||
31 | # spent 14.0ms (5.68+8.32) within Exporter::import which was called 47 times, avg 298µs/call:
# once (688µs+6.31ms) by POSIX::import at line 29 of POSIX.pm
# once (936µs+214µs) by POSIX::BEGIN@13 at line 13 of POSIX.pm
# once (137µs+457µs) by MARC::Charset::Code::BEGIN@8 at line 8 of MARC/Charset/Code.pm
# once (39µs+417µs) by MARC::Charset::Table::BEGIN@39 at line 39 of MARC/Charset/Table.pm
# once (41µs+405µs) by MARC::Charset::BEGIN@14 at line 14 of MARC/Charset.pm
# once (334µs+49µs) by Storable::BEGIN@23 at line 39 of FileHandle.pm
# once (317µs+39µs) by MARC::File::XML::BEGIN@12 at line 12 of lib/MARC/File/XML.pm
# once (297µs+36µs) by Storable::BEGIN@23 at line 26 of IO/File.pm
# once (209µs+36µs) by MARC::Charset::BEGIN@11 at line 11 of MARC/Charset.pm
# once (38µs+169µs) by Storable::BEGIN@44 at line 45 of Storable.pm
# once (144µs+20µs) by MARC::Charset::Table::BEGIN@40 at line 40 of MARC/Charset/Table.pm
# once (139µs+12µs) by MARC::File::Encode::BEGIN@22 at line 22 of MARC/File/Encode.pm
# once (94µs+11µs) by MARC::Record::BEGIN@15 at line 15 of MARC/Record.pm
# once (83µs+13µs) by IO::Handle::BEGIN@7 at line 7 of IO/Handle.pm
# once (85µs+6µs) by Carp::BEGIN@5 at line 5 of Carp/Heavy.pm
# once (84µs+5µs) by MARC::File::XML::BEGIN@11 at line 11 of lib/MARC/File/XML.pm
# once (83µs+5µs) by MARC::Charset::BEGIN@10 at line 10 of MARC/Charset.pm
# once (83µs+4µs) by IO::File::BEGIN@9 at line 9 of IO/File.pm
# once (81µs+5µs) by MARC::Field::BEGIN@5 at line 5 of MARC/Field.pm
# once (80µs+6µs) by SelectSaver::BEGIN@6 at line 6 of SelectSaver.pm
# once (76µs+6µs) by IO::BEGIN@6 at line 6 of IO.pm
# once (77µs+5µs) by Data::Dumper::BEGIN@20 at line 20 of Data/Dumper.pm
# once (77µs+5µs) by XML::SAX::Exception::BEGIN@10 at line 10 of XML/SAX/Exception.pm
# once (75µs+4µs) by XML::LibXML::XPathContext::BEGIN@15 at line 15 of XML/LibXML/XPathContext.pm
# once (69µs+8µs) by SelectSaver::BEGIN@7 at line 7 of SelectSaver.pm
# once (72µs+4µs) by XML::LibXML::Element::BEGIN@1481 at line 1481 of XML/LibXML.pm
# once (69µs+5µs) by Tie::Hash::BEGIN@5 at line 5 of Tie/Hash.pm
# once (69µs+5µs) by Unicode::Normalize::BEGIN@12 at line 12 of Unicode/Normalize.pm
# once (70µs+4µs) by MARC::File::USMARC::BEGIN@13 at line 13 of MARC/File/USMARC.pm
# once (68µs+5µs) by XML::LibXML::BEGIN@18 at line 18 of XML/LibXML.pm
# once (68µs+4µs) by IO::Seekable::BEGIN@6 at line 6 of IO/Seekable.pm
# once (68µs+4µs) by IO::File::BEGIN@8 at line 8 of IO/File.pm
# once (67µs+4µs) by IO::Handle::BEGIN@6 at line 6 of IO/Handle.pm
# once (67µs+4µs) by IO::File::BEGIN@11 at line 11 of IO/File.pm
# once (68µs+3µs) by Encode::BEGIN@48 at line 48 of Encode.pm
# once (65µs+5µs) by XML::LibXML::Error::BEGIN@13 at line 13 of XML/LibXML/Error.pm
# once (60µs+5µs) by IO::Seekable::BEGIN@12 at line 12 of IO/Seekable.pm
# once (59µs+4µs) by MARC::File::USMARC::BEGIN@18 at line 18 of MARC/File/USMARC.pm
# once (60µs+2µs) by XML::LibXML::Error::BEGIN@225 at line 225 of XML/LibXML/Error.pm
# once (58µs+2µs) by MARC::File::XML::BEGIN@13 at line 13 of lib/MARC/File/XML.pm
# once (54µs+2µs) by MARC::Charset::Code::BEGIN@7 at line 7 of MARC/Charset/Code.pm
# once (53µs+2µs) by MARC::Batch::BEGIN@28 at line 28 of MARC/Batch.pm
# once (51µs+2µs) by MARC::Charset::Code::BEGIN@6 at line 6 of MARC/Charset/Code.pm
# once (45µs+0s) by MARC::Record::BEGIN@26 at line 26 of MARC/Record.pm
# once (42µs+0s) by XML::LibXML::BEGIN@26 at line 26 of XML/LibXML.pm
# once (41µs+0s) by MARC::File::XML::BEGIN@7 at line 7 of lib/MARC/File/XML.pm
# once (36µs+0s) by main::BEGIN@4 at line 4 of conv.pl | ||||
32 | 690 | 3.18ms | my $pkg = shift; | ||
33 | my $callpkg = caller($ExportLevel); | ||||
34 | |||||
35 | if ($pkg eq "Exporter" and @_ and $_[0] eq "import") { | ||||
36 | *{$callpkg."::import"} = \&import; | ||||
37 | return; | ||||
38 | } | ||||
39 | |||||
40 | # We *need* to treat @{"$pkg\::EXPORT_FAIL"} since Carp uses it :-( | ||||
41 | my($exports, $fail) = (\@{"$pkg\::EXPORT"}, \@{"$pkg\::EXPORT_FAIL"}); | ||||
42 | return export $pkg, $callpkg, @_ | ||||
43 | if $Verbose or $Debug or @$fail > 1; | ||||
44 | my $export_cache = ($Cache{$pkg} ||= {}); | ||||
45 | my $args = @_ or @_ = @$exports; | ||||
46 | |||||
47 | local $_; | ||||
48 | 18 | 1.39ms | if ($args and not %$export_cache) { | ||
49 | s/^&//, $export_cache->{$_} = 1 | ||||
50 | 257 | 279µs | foreach (@$exports, @{"$pkg\::EXPORT_OK"}); # spent 279µs making 257 calls to Exporter::CORE:subst, avg 1µs/call | ||
51 | } | ||||
52 | 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 | 94 | 1.98ms | if ($args or $fail) { | ||
56 | ($heavy = (/\W/ or $args and not exists $export_cache->{$_} | ||||
57 | or @$fail and $_ eq $fail->[0])) and last | ||||
58 | 340 | 441µs | foreach (@_); # spent 441µs making 340 calls to Exporter::CORE:match, avg 1µs/call | ||
59 | } else { | ||||
60 | ($heavy = /\W/) and last | ||||
61 | foreach (@_); | ||||
62 | } | ||||
63 | 5 | 139µs | return export $pkg, $callpkg, ($args ? @_ : ()) if $heavy; # spent 139µs making 5 calls to Exporter::export, avg 28µs/call | ||
64 | local $SIG{__WARN__} = | ||||
65 | sub {require Carp; &Carp::carp}; | ||||
66 | # shortcut for the common case of no type character | ||||
67 | *{"$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 | # spent 2.42ms (26µs+2.40) within Exporter::export_to_level which was called 3 times, avg 807µs/call:
# 3 times (26µs+2.40ms) by XML::LibXML::import at line 206 of XML/LibXML.pm, avg 807µs/call | ||||
82 | 3 | 34µs | 6 | 3.90ms | goto &{as_heavy()}; # spent 2.40ms making 3 calls to Exporter::as_heavy, avg 799µs/call
# spent 1.50ms making 3 calls to Exporter::Heavy::heavy_export_to_level, avg 501µs/call |
83 | } | ||||
84 | |||||
85 | sub export_tags { | ||||
86 | goto &{as_heavy()}; | ||||
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__ | ||||
# spent 441µs within Exporter::CORE:match which was called 340 times, avg 1µs/call:
# 340 times (441µs+0s) by Exporter::import at line 58, avg 1µs/call | |||||
sub Exporter::CORE:subst; # opcode |