← Index
NYTProf Performance Profile   « line view »
For scripts/bench.pl
  Run on Mon Oct 22 16:48:56 2018
Reported on Mon Oct 22 16:49:10 2018

Filename/usr/share/perl/5.26/Exporter.pm
StatementsExecuted 16 statements in 211µs
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
2212.26ms2.34msExporter::::as_heavyExporter::as_heavy
2117µs7µsExporter::::CORE:substExporter::CORE:subst (opcode)
1116µs2.34msExporter::::export_to_levelExporter::export_to_level
1114µs12µ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::::importExporter::import
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
3117µsrequire 5.006;
4
5# Be lean.
6#use strict;
7#no strict 'refs';
8
91600nsour $Debug = 0;
101300nsour $ExportLevel = 0;
111600nsour $Verbose ||= 0;
121800nsour $VERSION = '5.72';
13our (%Cache);
14
15
# spent 2.34ms (2.26+87µs) within Exporter::as_heavy which was called 2 times, avg 1.17ms/call: # once (2.25ms+85µs) by Exporter::export_to_level at line 81 # once (6µs+2µs) by Exporter::export at line 25
sub as_heavy {
162136µ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
1925µs my $c = (caller(1))[3];
20216µs27µs $c =~ s/.*:://;
# spent 7µs making 2 calls to Exporter::CORE:subst, avg 3µs/call
2128µs \&{"Exporter::Heavy::heavy_$c"};
22}
23
24
# spent 12µs (4+9) within Exporter::export which was called: # once (4µs+9µs) by Exporter::Heavy::heavy_export_to_level at line 205 of Exporter/Heavy.pm
sub export {
2515µs2162µs goto &{as_heavy()};
# spent 154µs making 1 call to Exporter::Heavy::heavy_export # spent 9µs making 1 call to Exporter::as_heavy
26}
27
28sub import {
29 my $pkg = shift;
30 my $callpkg = caller($ExportLevel);
31
32 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 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 my $fail = ${$pkg . '::'}{EXPORT_FAIL} && \@{"$pkg\::EXPORT_FAIL"};
42 return export $pkg, $callpkg, @_
43 if $Verbose or $Debug or $fail && @$fail > 1;
44 my $export_cache = ($Cache{$pkg} ||= {});
45 my $args = @_ or @_ = @$exports;
46
47 if ($args and not %$export_cache) {
48 s/^&//, $export_cache->{$_} = 1
49 foreach (@$exports, @{"$pkg\::EXPORT_OK"});
50 }
51 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 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 foreach (@_);
58 } else {
59 ($heavy = /\W/) and last
60 foreach (@_);
61 }
62 return export $pkg, $callpkg, ($args ? @_ : ()) if $heavy;
63 local $SIG{__WARN__} =
64 sub {require Carp; &Carp::carp} if not $SIG{__WARN__};
65 # shortcut for the common case of no type character
66 *{"$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 2.34ms (6µs+2.34) within Exporter::export_to_level which was called: # once (6µs+2.34ms) by Time::HiRes::import at line 69 of Time/HiRes.pm
sub export_to_level {
8118µs22.51ms goto &{as_heavy()};
# spent 2.34ms making 1 call to Exporter::as_heavy # spent 179µs making 1 call to Exporter::Heavy::heavy_export_to_level
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
96112µs1;
97__END__
 
# spent 7µs within Exporter::CORE:subst which was called 2 times, avg 3µs/call: # 2 times (7µs+0s) by Exporter::as_heavy at line 20, avg 3µs/call
sub Exporter::CORE:subst; # opcode