← Index
NYTProf Performance Profile   « line view »
For split.pl
  Run on Thu Apr 20 02:05:47 2023
Reported on Thu Apr 20 18:31:09 2023

Filename/usr/lib/x86_64-linux-gnu/perl-base/Exporter/Heavy.pm
StatementsExecuted 1313 statements in 2.96ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
18111.77ms1.93msExporter::Heavy::::heavy_exportExporter::Heavy::heavy_export
90041103µs103µsExporter::Heavy::::CORE:substExporter::Heavy::CORE:subst (opcode)
11152µs53µsExporter::Heavy::::_rebuild_cacheExporter::Heavy::_rebuild_cache
41127µs207µsExporter::Heavy::::heavy_export_to_levelExporter::Heavy::heavy_export_to_level
21118µs18µsExporter::Heavy::::_push_tagsExporter::Heavy::_push_tags
15217µs7µsExporter::Heavy::::CORE:matchExporter::Heavy::CORE:match (opcode)
1117µs8µsExporter::Heavy::::BEGIN@3Exporter::Heavy::BEGIN@3
1116µs20µsExporter::Heavy::::BEGIN@188Exporter::Heavy::BEGIN@188
2116µs25µsExporter::Heavy::::heavy_export_tagsExporter::Heavy::heavy_export_tags
1113µs7µsExporter::Heavy::::BEGIN@4Exporter::Heavy::BEGIN@4
0000s0sExporter::Heavy::::__ANON__[:43]Exporter::Heavy::__ANON__[:43]
0000s0sExporter::Heavy::::__ANON__[:49]Exporter::Heavy::__ANON__[:49]
0000s0sExporter::Heavy::::heavy_export_ok_tagsExporter::Heavy::heavy_export_ok_tags
0000s0sExporter::Heavy::::heavy_require_versionExporter::Heavy::heavy_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::Heavy;
2
3219µs210µs
# spent 8µs (7+1) within Exporter::Heavy::BEGIN@3 which was called: # once (7µs+1µs) by Exporter::as_heavy at line 3
use strict;
# spent 8µs making 1 call to Exporter::Heavy::BEGIN@3 # spent 1µs making 1 call to strict::import
42632µs211µs
# spent 7µs (3+4) within Exporter::Heavy::BEGIN@4 which was called: # once (3µs+4µs) by Exporter::as_heavy at line 4
no strict 'refs';
# spent 7µs making 1 call to Exporter::Heavy::BEGIN@4 # spent 4µs making 1 call to strict::unimport
5
6# On one line so MakeMaker will see it.
71300nsour $VERSION = '5.77';
8
9#
10# We go to a lot of trouble not to 'require Carp' at file scope,
11# because Carp requires Exporter, and something has to give.
12#
13
14
# spent 53µs (52+600ns) within Exporter::Heavy::_rebuild_cache which was called: # once (52µs+600ns) by Exporter::Heavy::heavy_export at line 58
sub _rebuild_cache {
151300ns my ($pkg, $exports, $cache) = @_;
161700ns s/^&// foreach @$exports;
171800ns @{$cache}{@$exports} = (1) x @$exports;
181900ns my $ok = \@{"${pkg}::EXPORT_OK"};
1912µs if (@$ok) {
20135µs61600ns s/^&// foreach @$ok;
# spent 600ns making 61 calls to Exporter::Heavy::CORE:subst, avg 10ns/call
21113µs @{$cache}{@$ok} = (1) x @$ok;
22 }
23}
24
25
# spent 1.93ms (1.77+163µs) within Exporter::Heavy::heavy_export which was called 18 times, avg 107µs/call: # 18 times (1.77ms+163µs) by Carp::Assert::_export_to_level or Exporter::Heavy::heavy_export_to_level or Exporter::import or FileHandle::import at line 22 of Exporter.pm, avg 107µs/call
sub heavy_export {
26
27 # Save the old __WARN__ handler in case it was defined
281815µs my $oldwarn = $SIG{__WARN__};
29
30 # First make import warnings look like they're coming from the "use".
31 local $SIG{__WARN__} = sub {
32 # restore it back so proper stacking occurs
33 local $SIG{__WARN__} = $oldwarn;
34 my $text = shift;
35 if ($text =~ s/ at \S*Exporter\S*.pm line \d+.*\n//) {
36 require Carp;
37 local $Carp::CarpLevel = 1; # ignore package calling us too.
38 Carp::carp($text);
39 }
40 else {
41 warn $text;
42 }
431861µs };
44 local $SIG{__DIE__} = sub {
45 require Carp;
46 local $Carp::CarpLevel = 1; # ignore package calling us too.
47 Carp::croak("$_[0]Illegal null symbol in \@${1}::EXPORT")
48 if $_[0] =~ /^Unable to create sub named "(.*?)::"/;
491835µs };
50
51189µs my($pkg, $callpkg, @imports) = @_;
52184µs my($type, $sym, $cache_is_current, $oops);
53 my($exports, $export_cache) = (\@{"${pkg}::EXPORT"},
541830µs $Exporter::Cache{$pkg} ||= {});
55
56188µs if (@imports) {
5772µs if (!%$export_cache) {
5812µs153µs _rebuild_cache ($pkg, $exports, $export_cache);
# spent 53µs making 1 call to Exporter::Heavy::_rebuild_cache
591300ns $cache_is_current = 1;
60 }
61
62723µs115µs if (grep m{^[/!:]}, @imports) {
# spent 5µs making 11 calls to Exporter::Heavy::CORE:match, avg 491ns/call
6344µs my $tagsref = \%{"${pkg}::EXPORT_TAGS"};
644800ns my $tagdata;
65 my %imports;
66 my($remove, $spec, @names, @allexports);
67 # negated first item implies starting with default set:
6846µs42µs unshift @imports, ':DEFAULT' if $imports[0] =~ m/^!/;
# spent 2µs making 4 calls to Exporter::Heavy::CORE:match, avg 425ns/call
6942µs foreach $spec (@imports){
7046µs42µs $remove = $spec =~ s/^!//;
# spent 2µs making 4 calls to Exporter::Heavy::CORE:subst, avg 425ns/call
71
7247µs43µs if ($spec =~ s/^://){
# spent 3µs making 4 calls to Exporter::Heavy::CORE:subst, avg 775ns/call
73411µs if ($spec eq 'DEFAULT'){
74 @names = @$exports;
75 }
76 elsif ($tagdata = $tagsref->{$spec}) {
77 @names = @$tagdata;
78 }
79 else {
80 warn qq["$spec" is not defined in %${pkg}::EXPORT_TAGS];
81 ++$oops;
82 next;
83 }
84 }
85 elsif ($spec =~ m:^/(.*)/$:){
86 my $patn = $1;
87 @allexports = keys %$export_cache unless @allexports; # only do keys once
88 @names = grep(/$patn/, @allexports); # not anchored by default
89 }
90 else {
91 @names = ($spec); # is a normal symbol name
92 }
93
9441µs warn "Import ".($remove ? "del":"add").": @names "
95 if $Exporter::Verbose;
96
9742µs if ($remove) {
98 foreach $sym (@names) { delete $imports{$sym} }
99 }
100 else {
101424µs @imports{@names} = (1) x @names;
102 }
103 }
104416µs @imports = keys %imports;
105 }
106
10771µs my @carp;
10872µs foreach $sym (@imports) {
10912926µs if (!$export_cache->{$sym}) {
110 if ($sym =~ m/^\d/) {
111 $pkg->VERSION($sym); # inherit from UNIVERSAL
112 # If the version number was the only thing specified
113 # then we should act as if nothing was specified:
114 if (@imports == 1) {
115 @imports = @$exports;
116 last;
117 }
118 # We need a way to emulate 'use Foo ()' but still
119 # allow an easy version check: "use Foo 1.23, ''";
120 if (@imports == 2 and !$imports[1]) {
121 @imports = ();
122 last;
123 }
124 } elsif ($sym !~ s/^&// || !$export_cache->{$sym}) {
125 # Last chance - see if they've updated EXPORT_OK since we
126 # cached it.
127
128 unless ($cache_is_current) {
129 %$export_cache = ();
130 _rebuild_cache ($pkg, $exports, $export_cache);
131 $cache_is_current = 1;
132 }
133
134 if (!$export_cache->{$sym}) {
135 # accumulate the non-exports
136 push @carp,
137 qq["$sym" is not exported by the $pkg module];
138 $oops++;
139 }
140 }
141 }
142 }
14372µs if ($oops) {
144 require Carp;
145 Carp::croak(join("\n", @carp, "Can't continue after import errors"));
146 }
147 }
148 else {
1491158µs @imports = @$exports;
150 }
151
152 my($fail, $fail_cache) = (\@{"${pkg}::EXPORT_FAIL"},
1531838µs $Exporter::FailCache{$pkg} ||= {});
154
155184µs if (@$fail) {
156 if (!%$fail_cache) {
157 # Build cache of symbols. Optimise the lookup by adding
158 # barewords twice... both with and without a leading &.
159 # (Technique could be applied to $export_cache at cost of memory)
160 my @expanded = map { /^\w/ ? ($_, '&'.$_) : $_ } @$fail;
161 warn "${pkg}::EXPORT_FAIL cached: @expanded" if $Exporter::Verbose;
162 @{$fail_cache}{@expanded} = (1) x @expanded;
163 }
164 my @failed;
165 foreach $sym (@imports) { push(@failed, $sym) if $fail_cache->{$sym} }
166 if (@failed) {
167 @failed = $pkg->export_fail(@failed);
168 foreach $sym (@failed) {
169 require Carp;
170 Carp::carp(qq["$sym" is not implemented by the $pkg module ],
171 "on this architecture");
172 }
173 if (@failed) {
174 require Carp;
175 Carp::croak("Can't continue after import errors");
176 }
177 }
178 }
179
180184µs warn "Importing into $callpkg from $pkg: ",
181 join(", ",sort @imports) if $Exporter::Verbose;
182
18318179µs foreach $sym (@imports) {
184 # shortcut for the common case of no type character
1858311.29ms83198µs (*{"${callpkg}::$sym"} = \&{"${pkg}::$sym"}, next)
# spent 98µs making 831 calls to Exporter::Heavy::CORE:subst, avg 118ns/call
186 unless $sym =~ s/^(\W)//;
18785µs $type = $1;
1882316µs235µs
# spent 20µs (6+14) within Exporter::Heavy::BEGIN@188 which was called: # once (6µs+14µs) by Exporter::as_heavy at line 188
no warnings 'once';
# spent 20µs making 1 call to Exporter::Heavy::BEGIN@188 # spent 14µs making 1 call to warnings::unimport
189 *{"${callpkg}::$sym"} =
190 $type eq '&' ? \&{"${pkg}::$sym"} :
191 $type eq '$' ? \${"${pkg}::$sym"} :
192 $type eq '@' ? \@{"${pkg}::$sym"} :
193 $type eq '%' ? \%{"${pkg}::$sym"} :
194 $type eq '*' ? *{"${pkg}::$sym"} :
195819µs do { require Carp; Carp::croak("Can't export symbol: $type$sym") };
196 }
197}
198
199sub heavy_export_to_level
200
# spent 207µs (27+180) within Exporter::Heavy::heavy_export_to_level which was called 4 times, avg 52µs/call: # 4 times (27µs+180µs) by JSON::import or Time::HiRes::import at line 78 of Exporter.pm, avg 52µs/call
{
20141µs my $pkg = shift;
20241µs my $level = shift;
20342µs (undef) = shift; # XXX redundant arg
20442µs my $callpkg = caller($level);
205412µs421µs $pkg->export($callpkg, @_);
# spent 21µs making 4 calls to Exporter::export, avg 5µs/call
206}
207
208# Utility functions
209
210
# spent 18µs within Exporter::Heavy::_push_tags which was called 2 times, avg 9µs/call: # 2 times (18µs+0s) by Exporter::Heavy::heavy_export_tags at line 232, avg 9µs/call
sub _push_tags {
21121µs my($pkg, $var, $syms) = @_;
2122700ns my @nontag = ();
21322µs my $export_tags = \%{"${pkg}::EXPORT_TAGS"};
214 push(@{"${pkg}::$var"},
215212µs map { $export_tags->{$_} ? @{$export_tags->{$_}}
216 : scalar(push(@nontag,$_),$_) }
217 (@$syms) ? @$syms : keys %$export_tags);
21824µs if (@nontag and $^W) {
219 # This may change to a die one day
220 require Carp;
221 Carp::carp(join(", ", @nontag)." are not tags of $pkg");
222 }
223}
224
225sub heavy_require_version {
226 my($self, $wanted) = @_;
227 my $pkg = ref $self || $self;
228 return ${pkg}->VERSION($wanted);
229}
230
231
# spent 25µs (6+19) within Exporter::Heavy::heavy_export_tags which was called 2 times, avg 12µs/call: # 2 times (6µs+19µs) by Carp::Assert::BEGIN@10 or main::BEGIN@18 at line 82 of Exporter.pm, avg 12µs/call
sub heavy_export_tags {
23226µs218µs _push_tags((caller)[0], "EXPORT", \@_);
# spent 18µs making 2 calls to Exporter::Heavy::_push_tags, avg 9µs/call
233}
234
235sub heavy_export_ok_tags {
236 _push_tags((caller)[0], "EXPORT_OK", \@_);
237}
238
23912µs1;
 
# spent 7µs within Exporter::Heavy::CORE:match which was called 15 times, avg 473ns/call: # 11 times (5µs+0s) by Exporter::Heavy::heavy_export at line 62, avg 491ns/call # 4 times (2µs+0s) by Exporter::Heavy::heavy_export at line 68, avg 425ns/call
sub Exporter::Heavy::CORE:match; # opcode
# spent 103µs within Exporter::Heavy::CORE:subst which was called 900 times, avg 115ns/call: # 831 times (98µs+0s) by Exporter::Heavy::heavy_export at line 185, avg 118ns/call # 61 times (600ns+0s) by Exporter::Heavy::_rebuild_cache at line 20, avg 10ns/call # 4 times (3µs+0s) by Exporter::Heavy::heavy_export at line 72, avg 775ns/call # 4 times (2µs+0s) by Exporter::Heavy::heavy_export at line 70, avg 425ns/call
sub Exporter::Heavy::CORE:subst; # opcode