Filename | /usr/local/perls/perl-5.26.1/lib/5.26.1/Exporter.pm |
Statements | Executed 1098 statements in 6.11ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
69 | 69 | 32 | 4.82ms | 8.02ms | import | Exporter::
635 | 2 | 1 | 340µs | 340µs | CORE:match (opcode) | Exporter::
23 | 2 | 1 | 326µs | 446µs | as_heavy | Exporter::
116 | 2 | 1 | 154µs | 154µs | CORE:subst (opcode) | Exporter::
18 | 1 | 1 | 96µs | 438µs | export | Exporter::
5 | 5 | 5 | 54µs | 158µ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 | require 5.006; | ||||
4 | |||||
5 | # Be lean. | ||||
6 | #use strict; | ||||
7 | #no strict 'refs'; | ||||
8 | |||||
9 | our $Debug = 0; | ||||
10 | our $ExportLevel = 0; | ||||
11 | our $Verbose ||= 0; | ||||
12 | our $VERSION = '5.72'; | ||||
13 | our (%Cache); | ||||
14 | |||||
15 | sub as_heavy { | ||||
16 | 23 | 19µ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 | 23 | 143µs | my $c = (caller(1))[3]; | ||
20 | 23 | 189µs | 23 | 120µs | $c =~ s/.*:://; # spent 120µs making 23 calls to Exporter::CORE:subst, avg 5µs/call |
21 | 23 | 135µs | \&{"Exporter::Heavy::heavy_$c"}; | ||
22 | } | ||||
23 | |||||
24 | # spent 438µs (96+342) within Exporter::export which was called 18 times, avg 24µs/call:
# 18 times (96µs+342µs) by Exporter::import at line 62, avg 24µs/call | ||||
25 | 18 | 152µs | 36 | 2.73ms | goto &{as_heavy()}; # spent 2.39ms making 18 calls to Exporter::Heavy::heavy_export, avg 133µs/call
# spent 342µs making 18 calls to Exporter::as_heavy, avg 19µs/call |
26 | } | ||||
27 | |||||
28 | # spent 8.02ms (4.82+3.20) within Exporter::import which was called 69 times, avg 116µs/call:
# once (85µs+328µs) by IO::Compress::Adapter::Deflate::BEGIN@8 at line 8 of IO/Compress/Adapter/Deflate.pm
# once (302µs+25µs) by Archive::Tar::BEGIN@19 at line 19 of Archive/Tar.pm
# once (81µs+232µs) by Storable::BEGIN@59 at line 60 of Storable.pm
# once (272µs+16µs) by Archive::Tar::File::BEGIN@12 at line 12 of Archive/Tar/File.pm
# once (65µs+212µs) by File::Glob::import at line 46 of File/Glob.pm
# once (48µs+225µs) by IO::Compress::Gzip::BEGIN@15 at line 15 of IO/Compress/Gzip.pm
# once (57µs+203µs) by Compress::Zlib::BEGIN@464 at line 464 of Compress/Zlib.pm
# once (54µs+200µs) by IO::Compress::Zlib::Extra::BEGIN@13 at line 13 of IO/Compress/Zlib/Extra.pm
# once (232µs+17µs) by IO::Compress::RawDeflate::BEGIN@11 at line 11 of IO/Compress/RawDeflate.pm
# once (51µs+193µs) by IO::Uncompress::Gunzip::BEGIN@16 at line 16 of IO/Uncompress/Gunzip.pm
# once (209µs+15µs) by Compress::Zlib::BEGIN@11 at line 11 of Compress/Zlib.pm
# once (40µs+180µs) by IO::Uncompress::Bunzip2::BEGIN@7 at line 7 of IO/Uncompress/Bunzip2.pm
# once (74µs+145µs) by IO::Compress::RawDeflate::BEGIN@10 at line 10 of IO/Compress/RawDeflate.pm
# once (203µs+11µs) by IO::Uncompress::Adapter::Bunzip2::BEGIN@9 at line 9 of IO/Uncompress/Adapter/Bunzip2.pm
# once (200µs+11µs) by IO::Compress::Gzip::BEGIN@12 at line 12 of IO/Compress/Gzip.pm
# once (188µs+16µs) by IO::Uncompress::RawInflate::BEGIN@8 at line 8 of IO/Uncompress/RawInflate.pm
# once (175µs+7µs) by Archive::Tar::BEGIN@12 at line 12 of Archive/Tar.pm
# once (29µs+129µs) by IO::Uncompress::Adapter::Inflate::BEGIN@7 at line 7 of IO/Uncompress/Adapter/Inflate.pm
# once (149µs+8µs) by IO::Uncompress::Base::BEGIN@19 at line 19 of IO/Uncompress/Base.pm
# once (27µs+128µs) by IO::Compress::Adapter::Bzip2::BEGIN@7 at line 7 of IO/Compress/Adapter/Bzip2.pm
# once (20µs+134µs) by IO::Compress::Bzip2::BEGIN@54 at line 54 of IO/Compress/Bzip2.pm
# once (144µs+9µs) by IO::Uncompress::Base::BEGIN@17 at line 17 of IO/Uncompress/Base.pm
# once (142µs+8µs) by IO::Compress::Base::BEGIN@9 at line 9 of IO/Compress/Base.pm
# once (130µs+9µs) by Compress::Zlib::BEGIN@10 at line 10 of Compress/Zlib.pm
# once (126µs+11µs) by Archive::Tar::File::BEGIN@5 at line 5 of Archive/Tar/File.pm
# once (25µs+112µs) by IO::Compress::Gzip::BEGIN@14 at line 14 of IO/Compress/Gzip.pm
# once (20µs+116µs) by IO::Compress::RawDeflate::BEGIN@119 at line 119 of IO/Compress/RawDeflate.pm
# once (24µs+108µs) by IO::Compress::Adapter::Deflate::BEGIN@7 at line 7 of IO/Compress/Adapter/Deflate.pm
# once (26µs+105µs) by IO::Uncompress::Gunzip::BEGIN@15 at line 15 of IO/Uncompress/Gunzip.pm
# once (21µs+104µs) by IO::Uncompress::Adapter::Bunzip2::BEGIN@7 at line 7 of IO/Uncompress/Adapter/Bunzip2.pm
# once (18µs+107µs) by IO::Uncompress::RawInflate::BEGIN@9 at line 9 of IO/Uncompress/RawInflate.pm
# once (103µs+6µs) by Archive::Tar::BEGIN@10 at line 10 of Archive/Tar.pm
# once (102µs+5µs) by IO::Compress::Adapter::Bzip2::BEGIN@9 at line 9 of IO/Compress/Adapter/Bzip2.pm
# once (78µs+6µs) by URI::WithBase::BEGIN@7 at line 7 of URI/WithBase.pm
# once (68µs+5µs) by Compress::Zlib::BEGIN@6 at line 6 of Compress/Zlib.pm
# once (62µs+3µs) by URI::file::BEGIN@9 at line 9 of URI/file.pm
# once (58µs+2µs) by IO::Uncompress::Adapter::Inflate::BEGIN@8 at line 8 of IO/Uncompress/Adapter/Inflate.pm
# once (55µs+5µs) by URI::URL::BEGIN@19 at line 19 of URI/URL.pm
# once (55µs+3µs) by IO::Zlib::BEGIN@306 at line 306 of IO/Zlib.pm
# once (56µs+2µs) by Tie::Handle::BEGIN@123 at line 123 of Tie/Handle.pm
# once (51µs+2µs) by IO::Zlib::BEGIN@291 at line 291 of IO/Zlib.pm
# once (47µs+4µs) by URI::file::Unix::BEGIN@8 at line 8 of URI/file/Unix.pm
# once (43µs+5µs) by URI::_generic::BEGIN@8 at line 8 of URI/_generic.pm
# once (45µs+3µs) by URI::_query::BEGIN@7 at line 7 of URI/_query.pm
# once (47µs+1µs) by Digest::SHA::BEGIN@8 at line 8 of Digest/SHA.pm
# once (45µs+2µs) by IO::Compress::Base::Common::BEGIN@523 at line 523 of IO/Compress/Base/Common.pm
# once (43µs+4µs) by Compress::Raw::Zlib::BEGIN@6 at line 6 of Compress/Raw/Zlib.pm
# once (43µs+2µs) by Compress::Raw::Bzip2::BEGIN@9 at line 9 of Compress/Raw/Bzip2.pm
# once (43µs+0s) by IO::Compress::Bzip2::BEGIN@8 at line 8 of IO/Compress/Bzip2.pm
# once (41µs+1000ns) by IO::Uncompress::Base::BEGIN@20 at line 20 of IO/Uncompress/Base.pm
# once (38µs+3µs) by File::GlobMapper::BEGIN@5 at line 5 of File/GlobMapper.pm
# once (34µs+3µs) by IO::Compress::Base::Common::BEGIN@7 at line 7 of IO/Compress/Base/Common.pm
# once (34µs+2µs) by IO::Zlib::BEGIN@292 at line 292 of IO/Zlib.pm
# once (35µs+1µs) by Archive::Tar::BEGIN@13 at line 13 of Archive/Tar.pm
# once (31µs+2µs) by IO::Compress::Base::Common::BEGIN@8 at line 8 of IO/Compress/Base/Common.pm
# once (29µs+3µs) by IO::Compress::RawDeflate::BEGIN@120 at line 120 of IO/Compress/RawDeflate.pm
# once (29µs+2µs) by IO::Uncompress::Base::BEGIN@23 at line 23 of IO/Uncompress/Base.pm
# once (29µs+0s) by IO::Compress::Base::BEGIN@914 at line 914 of IO/Compress/Base.pm
# once (27µs+1µs) by Compress::Zlib::BEGIN@8 at line 8 of Compress/Zlib.pm
# once (25µs+1000ns) by IO::Compress::RawDeflate::BEGIN@150 at line 150 of IO/Compress/RawDeflate.pm
# once (25µs+0s) by IO::Uncompress::RawInflate::BEGIN@11 at line 11 of IO/Uncompress/RawInflate.pm
# once (24µs+0s) by IO::Compress::RawDeflate::BEGIN@9 at line 9 of IO/Compress/RawDeflate.pm
# once (24µs+0s) by Compress::Zlib::BEGIN@12 at line 12 of Compress/Zlib.pm
# once (22µs+0s) by IO::Uncompress::Bunzip2::BEGIN@9 at line 9 of IO/Uncompress/Bunzip2.pm
# once (22µs+0s) by URI::Escape::BEGIN@140 at line 140 of URI/Escape.pm
# once (21µs+0s) by IO::Uncompress::Gunzip::BEGIN@12 at line 12 of IO/Uncompress/Gunzip.pm
# once (19µs+0s) by Compress::Zlib::BEGIN@7 at line 7 of Compress/Zlib.pm
# once (19µs+0s) by Compress::Zlib::BEGIN@13 at line 13 of Compress/Zlib.pm
# once (9µs+0s) by URI::URL::BEGIN@13 at line 13 of URI/URL.pm | ||||
29 | 69 | 51µs | my $pkg = shift; | ||
30 | 69 | 74µs | my $callpkg = caller($ExportLevel); | ||
31 | |||||
32 | 69 | 40µs | if ($pkg eq "Exporter" and @_ and $_[0] eq "import") { | ||
33 | 2 | 13µs | *{$callpkg."::import"} = \&import; | ||
34 | 2 | 13µs | return; | ||
35 | } | ||||
36 | |||||
37 | # We *need* to treat @{"$pkg\::EXPORT_FAIL"} since Carp uses it :-( | ||||
38 | 67 | 233µ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 | 67 | 165µs | my $fail = ${$pkg . '::'}{EXPORT_FAIL} && \@{"$pkg\::EXPORT_FAIL"}; | ||
42 | 67 | 61µs | return export $pkg, $callpkg, @_ | ||
43 | if $Verbose or $Debug or $fail && @$fail > 1; | ||||
44 | 67 | 104µs | my $export_cache = ($Cache{$pkg} ||= {}); | ||
45 | 67 | 178µs | my $args = @_ or @_ = @$exports; | ||
46 | |||||
47 | 67 | 20µs | if ($args and not %$export_cache) { | ||
48 | s/^&//, $export_cache->{$_} = 1 | ||||
49 | 4 | 218µs | 93 | 34µs | foreach (@$exports, @{"$pkg\::EXPORT_OK"}); # spent 34µs making 93 calls to Exporter::CORE:subst, avg 366ns/call |
50 | } | ||||
51 | 67 | 11µ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 | 67 | 44µ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 | 42 | 635µs | 199 | 173µs | foreach (@_); # spent 173µs making 199 calls to Exporter::CORE:match, avg 869ns/call |
58 | } else { | ||||
59 | ($heavy = /\W/) and last | ||||
60 | 25 | 801µs | 436 | 167µs | foreach (@_); # spent 167µs making 436 calls to Exporter::CORE:match, avg 383ns/call |
61 | } | ||||
62 | 67 | 138µs | 18 | 438µs | return export $pkg, $callpkg, ($args ? @_ : ()) if $heavy; # spent 438µs making 18 calls to Exporter::export, avg 24µs/call |
63 | local $SIG{__WARN__} = | ||||
64 | 49 | 315µs | sub {require Carp; &Carp::carp} if not $SIG{__WARN__}; | ||
65 | # shortcut for the common case of no type character | ||||
66 | 49 | 2.30ms | *{"$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 158µs (54+104) within Exporter::export_ok_tags which was called 5 times, avg 32µs/call:
# once (21µs+19µs) by Archive::Tar::Constant::BEGIN@74 at line 24 of IO/Compress/Bzip2.pm
# once (10µs+24µs) by IO::Uncompress::Gunzip::BEGIN@12 at line 25 of IO/Uncompress/RawInflate.pm
# once (12µs+22µs) by IO::Compress::Gzip::BEGIN@11 at line 43 of IO/Compress/RawDeflate.pm
# once (6µs+20µs) by Compress::Zlib::BEGIN@12 at line 36 of IO/Compress/Gzip.pm
# once (5µs+19µs) by Compress::Zlib::BEGIN@13 at line 27 of IO/Uncompress/Gunzip.pm | ||||
89 | 5 | 60µs | 10 | 247µs | goto &{as_heavy()}; # spent 143µs making 5 calls to Exporter::Heavy::heavy_export_ok_tags, avg 29µs/call
# spent 104µs making 5 calls to Exporter::as_heavy, avg 21µs/call |
90 | } | ||||
91 | |||||
92 | sub require_version { | ||||
93 | goto &{as_heavy()}; | ||||
94 | } | ||||
95 | |||||
96 | 1; | ||||
97 | __END__ | ||||
sub Exporter::CORE:match; # opcode | |||||
sub Exporter::CORE:subst; # opcode |