← Index
NYTProf Performance Profile   « line view »
For examples/benchmark4.pl
  Run on Thu Aug 28 19:01:43 2014
Reported on Thu Aug 28 19:02:42 2014

Filename/usr/share/perl/5.18/Exporter.pm
StatementsExecuted 259 statements in 1.85ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
20211.56ms1.66msExporter::::as_heavyExporter::as_heavy
101081.37ms1.44msExporter::::importExporter::import
3702182µs82µsExporter::::CORE:substExporter::CORE:subst (opcode)
106636µs1.64msExporter::::export_to_levelExporter::export_to_level
1912135µs35µsExporter::::CORE:matchExporter::CORE:match (opcode)
101131µs93µsExporter::::exportExporter::export
0000s0sExporter::::__ANON__[:64]Exporter::__ANON__[:64]
0000s0sExporter::::export_failExporter::export_fail
0000s0sExporter::::export_ok_tagsExporter::export_ok_tags
0000s0sExporter::::export_tagsExporter::export_tags
0000s0sExporter::::require_versionExporter::require_version
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package Exporter;
2
318µsrequire 5.006;
4
5# Be lean.
6#use strict;
7#no strict 'refs';
8
91300nsour $Debug = 0;
101100nsour $ExportLevel = 0;
111300nsour $Verbose ||= 0;
121300nsour $VERSION = '5.68';
131200nsour (%Cache);
14
15
# spent 1.66ms (1.56+99µs) within Exporter::as_heavy which was called 20 times, avg 83µs/call: # 10 times (1.52ms+85µs) by Exporter::export_to_level at line 81, avg 160µs/call # 10 times (48µs+14µs) by Exporter::export at line 25, avg 6µs/call
sub as_heavy {
162089µ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
192035µs my $c = (caller(1))[3];
202092µs2043µs $c =~ s/.*:://;
# spent 43µs making 20 calls to Exporter::CORE:subst, avg 2µs/call
212063µs \&{"Exporter::Heavy::heavy_$c"};
22}
23
24
# spent 93µs (31+62) within Exporter::export which was called 10 times, avg 9µs/call: # 10 times (31µs+62µs) by Exporter::Heavy::heavy_export_to_level at line 200 of Exporter/Heavy.pm, avg 9µs/call
sub export {
251033µs20913µs goto &{as_heavy()};
# spent 851µs making 10 calls to Exporter::Heavy::heavy_export, avg 85µs/call # spent 62µs making 10 calls to Exporter::as_heavy, avg 6µs/call
26}
27
28
# spent 1.44ms (1.37+73µs) within Exporter::import which was called 10 times, avg 144µs/call: # once (577µs+23µs) by NetAddr::IP::UtilPolluted::BEGIN@198 at line 198 of NetAddr/IP/Util.pm # once (432µs+31µs) by NetAddr::IP::FastNew::BEGIN@7 at line 7 of lib/NetAddr/IP/FastNew.pm # once (160µs+10µs) by NetAddr::IP::Lite::BEGIN@9 at line 86 of NetAddr/IP/InetBase.pm # once (36µs+2µs) by Benchmark::BEGIN@432 at line 432 of Benchmark.pm # once (34µs+2µs) by NetAddr::IP::BEGIN@7 at line 7 of NetAddr/IP.pm # once (31µs+1µs) by Socket::BEGIN@10 at line 10 of Socket.pm # once (31µs+2µs) by NetAddr::IP::Lite::BEGIN@5 at line 5 of NetAddr/IP/Lite.pm # once (30µs+1µs) by Socket6::BEGIN@213 at line 213 of Socket6.pm # once (24µs+1µs) by NetAddr::IP::Lite::BEGIN@18 at line 239 of NetAddr/IP/Util.pm # once (14µs+0s) by Benchmark::BEGIN@433 at line 433 of Benchmark.pm
sub import {
29104µs my $pkg = shift;
30106µs my $callpkg = caller($ExportLevel);
31
32104µ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 :-(
381015µ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.
411010µs my $fail = ${$pkg . '::'}{EXPORT_FAIL} && \@{"$pkg\::EXPORT_FAIL"};
42105µs return export $pkg, $callpkg, @_
43 if $Verbose or $Debug or $fail && @$fail > 1;
44106µs my $export_cache = ($Cache{$pkg} ||= {});
451032µs my $args = @_ or @_ = @$exports;
46
47103µs if ($args and not %$export_cache) {
48 s/^&//, $export_cache->{$_} = 1
492576µs35039µs foreach (@$exports, @{"$pkg\::EXPORT_OK"});
# spent 39µs making 350 calls to Exporter::CORE:subst, avg 110ns/call
50 }
51101µ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.
54105µ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
57872µs2212µs foreach (@_);
# spent 12µs making 22 calls to Exporter::CORE:match, avg 545ns/call
58 } else {
59 ($heavy = /\W/) and last
602227µs16923µs foreach (@_);
# spent 23µs making 169 calls to Exporter::CORE:match, avg 134ns/call
61 }
62101µs return export $pkg, $callpkg, ($args ? @_ : ()) if $heavy;
63 local $SIG{__WARN__} =
641046µs sub {require Carp; &Carp::carp} if not $SIG{__WARN__};
65 # shortcut for the common case of no type character
6610457µs *{"$callpkg\::$_"} = \&{"$pkg\::$_"} foreach @_;
67}
68
69# Default methods
70
71sub 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
# spent 1.64ms (36µs+1.60) within Exporter::export_to_level which was called 10 times, avg 164µs/call: # 3 times (10µs+34µs) by NetAddr::IP::Util::import at line 189 of NetAddr/IP/Util.pm, avg 14µs/call # 2 times (8µs+20µs) by NetAddr::IP::import at line 406 of NetAddr/IP.pm, avg 14µs/call # 2 times (7µs+21µs) by NetAddr::IP::InetBase::import at line 277 of NetAddr/IP/InetBase.pm, avg 14µs/call # once (5µs+1.51ms) by Time::HiRes::import at line 63 of Time/HiRes.pm # once (3µs+11µs) by NetAddr::IP::Lite::import at line 1591 of NetAddr/IP/Lite.pm # once (3µs+10µs) by Benchmark::import at line 467 of Benchmark.pm
sub export_to_level {
811050µs202.63ms goto &{as_heavy()};
# spent 1.60ms making 10 calls to Exporter::as_heavy, avg 160µs/call # spent 1.02ms making 10 calls to Exporter::Heavy::heavy_export_to_level, avg 102µs/call
82}
83
84sub export_tags {
85 goto &{as_heavy()};
86}
87
88sub export_ok_tags {
89 goto &{as_heavy()};
90}
91
92sub require_version {
93 goto &{as_heavy()};
94}
95
9614µs1;
97__END__
 
# spent 35µs within Exporter::CORE:match which was called 191 times, avg 182ns/call: # 169 times (23µs+0s) by Exporter::import at line 60, avg 134ns/call # 22 times (12µs+0s) by Exporter::import at line 57, avg 545ns/call
sub Exporter::CORE:match; # opcode
# spent 82µs within Exporter::CORE:subst which was called 370 times, avg 221ns/call: # 350 times (39µs+0s) by Exporter::import at line 49, avg 110ns/call # 20 times (43µs+0s) by Exporter::as_heavy at line 20, avg 2µs/call
sub Exporter::CORE:subst; # opcode