← Index
NYTProf Performance Profile   « block view • line view • sub view »
For 01.HTTP.t
  Run on Tue May 4 15:25:55 2010
Reported on Tue May 4 15:26:19 2010

File /usr/local/lib/perl5/5.10.1/Exporter/Heavy.pm
Statements Executed 913
Statement Execution Time 5.17ms
Subroutines — ordered by exclusive time
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
14112.69ms2.99msExporter::Heavy::::heavy_exportExporter::Heavy::heavy_export
58942206µs206µsExporter::Heavy::::CORE:substExporter::Heavy::CORE:subst (opcode)
11175µs80µsExporter::Heavy::::_rebuild_cacheExporter::Heavy::_rebuild_cache
21134µs456µsExporter::Heavy::::heavy_export_to_levelExporter::Heavy::heavy_export_to_level
21120µs20µsExporter::Heavy::::_push_tagsExporter::Heavy::_push_tags
11120µs25µsExporter::Heavy::::BEGIN@3Exporter::Heavy::BEGIN@3
11112µs24µsExporter::Heavy::::BEGIN@200Exporter::Heavy::BEGIN@200
21111µs32µsExporter::Heavy::::heavy_export_ok_tagsExporter::Heavy::heavy_export_ok_tags
173211µs11µsExporter::Heavy::::CORE:matchExporter::Heavy::CORE:match (opcode)
1117µs22µsExporter::Heavy::::BEGIN@4Exporter::Heavy::BEGIN@4
0000s0sExporter::Heavy::::__ANON__[:55]Exporter::Heavy::__ANON__[:55]
0000s0sExporter::Heavy::::__ANON__[:61]Exporter::Heavy::__ANON__[:61]
0000s0sExporter::Heavy::::heavy_export_tagsExporter::Heavy::heavy_export_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
3334µs230µs
# spent 25µs (20+5) within Exporter::Heavy::BEGIN@3 which was called # once (20µs+5µs) by Exporter::as_heavy at line 3
use strict;
# spent 25µs making 1 call to Exporter::Heavy::BEGIN@3 # spent 5µs making 1 call to strict::import
431.12ms238µs
# spent 22µs (7+15) within Exporter::Heavy::BEGIN@4 which was called # once (7µs+15µs) by Exporter::as_heavy at line 4
no strict 'refs';
# spent 22µs making 1 call to Exporter::Heavy::BEGIN@4 # spent 15µs making 1 call to strict::unimport
5
6# On one line so MakeMaker will see it.
724µsrequire Exporter; our $VERSION = $Exporter::VERSION;
8
9# Carp 1.05+ does this now for us, but we may be running with an old Carp
1012µs$Carp::Internal{'Exporter::Heavy'}++;
11
12=head1 NAME
13
14Exporter::Heavy - Exporter guts
15
16=head1 SYNOPSIS
17
18(internal use only)
19
20=head1 DESCRIPTION
21
22No user-serviceable parts inside.
23
24=cut
25
26#
27# We go to a lot of trouble not to 'require Carp' at file scope,
28# because Carp requires Exporter, and something has to give.
29#
30
31
# spent 80µs (75+4) within Exporter::Heavy::_rebuild_cache which was called # once (75µs+4µs) by Exporter::Heavy::heavy_export at line 70
sub _rebuild_cache {
3211µs my ($pkg, $exports, $cache) = @_;
3322µs s/^&// foreach @$exports;
3412µs @{$cache}{@$exports} = (1) x @$exports;
3512µs my $ok = \@{"${pkg}::EXPORT_OK"};
3613µs if (@$ok) {
37249µs384µs s/^&// foreach @$ok;
# spent 4µs making 38 calls to Exporter::Heavy::CORE:subst, avg 116ns/call
38114µs @{$cache}{@$ok} = (1) x @$ok;
39 }
40}
41
42
# spent 2.99ms (2.69+292µs) within Exporter::Heavy::heavy_export which was called 14 times, avg 213µs/call: # 14 times (2.69ms+292µs) by Exporter::Heavy::heavy_export_to_level or Exporter::import or FileHandle::import or IO::Socket::import at line 28 of Exporter.pm, avg 213µs/call
sub heavy_export {
43
44 # First make import warnings look like they're coming from the "use".
45 local $SIG{__WARN__} = sub {
46 my $text = shift;
47 if ($text =~ s/ at \S*Exporter\S*.pm line \d+.*\n//) {
48 require Carp;
49 local $Carp::CarpLevel = 1; # ignore package calling us too.
50 Carp::carp($text);
51 }
52 else {
53 warn $text;
54 }
551474µs };
56 local $SIG{__DIE__} = sub {
57 require Carp;
58 local $Carp::CarpLevel = 1; # ignore package calling us too.
59 Carp::croak("$_[0]Illegal null symbol in \@${1}::EXPORT")
60 if $_[0] =~ /^Unable to create sub named "(.*?)::"/;
611459µs };
62
631418µs my($pkg, $callpkg, @imports) = @_;
64146µs my($type, $sym, $cache_is_current, $oops);
651431µs my($exports, $export_cache) = (\@{"${pkg}::EXPORT"},
66 $Exporter::Cache{$pkg} ||= {});
67
681454µs if (@imports) {
6979µs if (!%$export_cache) {
7013µs180µs _rebuild_cache ($pkg, $exports, $export_cache);
# spent 80µs making 1 call to Exporter::Heavy::_rebuild_cache
711500ns $cache_is_current = 1;
72 }
73
74739µs97µs if (grep m{^[/!:]}, @imports) {
# spent 7µs making 9 calls to Exporter::Heavy::CORE:match, avg 778ns/call
75610µs my $tagsref = \%{"${pkg}::EXPORT_TAGS"};
7661µs my $tagdata;
776900ns my %imports;
7862µs my($remove, $spec, @names, @allexports);
79 # negated first item implies starting with default set:
80613µs62µs unshift @imports, ':DEFAULT' if $imports[0] =~ m/^!/;
# spent 2µs making 6 calls to Exporter::Heavy::CORE:match, avg 383ns/call
8165µs foreach $spec (@imports){
82816µs83µs $remove = $spec =~ s/^!//;
# spent 3µs making 8 calls to Exporter::Heavy::CORE:subst, avg 362ns/call
83
84829µs108µs if ($spec =~ s/^://){
# spent 6µs making 8 calls to Exporter::Heavy::CORE:subst, avg 762ns/call # spent 1µs making 2 calls to Exporter::Heavy::CORE:match, avg 700ns/call
85625µs if ($spec eq 'DEFAULT'){
86 @names = @$exports;
87 }
88 elsif ($tagdata = $tagsref->{$spec}) {
89 @names = @$tagdata;
90 }
91 else {
92 warn qq["$spec" is not defined in %${pkg}::EXPORT_TAGS];
93 ++$oops;
94 next;
95 }
96 }
97 elsif ($spec =~ m:^/(.*)/$:){
98 my $patn = $1;
99 @allexports = keys %$export_cache unless @allexports; # only do keys once
100 @names = grep(/$patn/, @allexports); # not anchored by default
101 }
102 else {
10322µs @names = ($spec); # is a normal symbol name
104 }
105
10681µs warn "Import ".($remove ? "del":"add").": @names "
107 if $Exporter::Verbose;
108
10988µs if ($remove) {
110 foreach $sym (@names) { delete $imports{$sym} }
111 }
112 else {
113823µs @imports{@names} = (1) x @names;
114 }
115 }
116626µs @imports = keys %imports;
117 }
118
11971µs my @carp;
12075µs foreach $sym (@imports) {
1214615µs if (!$export_cache->{$sym}) {
122 if ($sym =~ m/^\d/) {
123 $pkg->VERSION($sym); # inherit from UNIVERSAL
124 # If the version number was the only thing specified
125 # then we should act as if nothing was specified:
126 if (@imports == 1) {
127 @imports = @$exports;
128 last;
129 }
130 # We need a way to emulate 'use Foo ()' but still
131 # allow an easy version check: "use Foo 1.23, ''";
132 if (@imports == 2 and !$imports[1]) {
133 @imports = ();
134 last;
135 }
136 } elsif ($sym !~ s/^&// || !$export_cache->{$sym}) {
137 # Last chance - see if they've updated EXPORT_OK since we
138 # cached it.
139
140 unless ($cache_is_current) {
141 %$export_cache = ();
142 _rebuild_cache ($pkg, $exports, $export_cache);
143 $cache_is_current = 1;
144 }
145
146 if (!$export_cache->{$sym}) {
147 # accumulate the non-exports
148 push @carp,
149 qq["$sym" is not exported by the $pkg module\n];
150 $oops++;
151 }
152 }
153 }
154 }
15573µs if ($oops) {
156 require Carp;
157 Carp::croak("@{carp}Can't continue after import errors");
158 }
159 }
160 else {
1617151µs @imports = @$exports;
162 }
163
1641440µs my($fail, $fail_cache) = (\@{"${pkg}::EXPORT_FAIL"},
165 $Exporter::FailCache{$pkg} ||= {});
166
167145µs if (@$fail) {
168 if (!%$fail_cache) {
169 # Build cache of symbols. Optimise the lookup by adding
170 # barewords twice... both with and without a leading &.
171 # (Technique could be applied to $export_cache at cost of memory)
172 my @expanded = map { /^\w/ ? ($_, '&'.$_) : $_ } @$fail;
173 warn "${pkg}::EXPORT_FAIL cached: @expanded" if $Exporter::Verbose;
174 @{$fail_cache}{@expanded} = (1) x @expanded;
175 }
176 my @failed;
177 foreach $sym (@imports) { push(@failed, $sym) if $fail_cache->{$sym} }
178 if (@failed) {
179 @failed = $pkg->export_fail(@failed);
180 foreach $sym (@failed) {
181 require Carp;
182 Carp::carp(qq["$sym" is not implemented by the $pkg module ],
183 "on this architecture");
184 }
185 if (@failed) {
186 require Carp;
187 Carp::croak("Can't continue after import errors");
188 }
189 }
190 }
191
192143µs warn "Importing into $callpkg from $pkg: ",
193 join(", ",sort @imports) if $Exporter::Verbose;
194
19514248µs foreach $sym (@imports) {
196 # shortcut for the common case of no type character
1975351.83ms535193µs (*{"${callpkg}::$sym"} = \&{"${pkg}::$sym"}, next)
# spent 193µs making 535 calls to Exporter::Heavy::CORE:subst, avg 360ns/call
198 unless $sym =~ s/^(\W)//;
19977µs $type = $1;
20031.08ms236µs
# spent 24µs (12+12) within Exporter::Heavy::BEGIN@200 which was called # once (12µs+12µs) by Exporter::as_heavy at line 200
no warnings 'once';
# spent 24µs making 1 call to Exporter::Heavy::BEGIN@200 # spent 12µs making 1 call to warnings::unimport
201 *{"${callpkg}::$sym"} =
202 $type eq '&' ? \&{"${pkg}::$sym"} :
203 $type eq '$' ? \${"${pkg}::$sym"} :
204 $type eq '@' ? \@{"${pkg}::$sym"} :
205 $type eq '%' ? \%{"${pkg}::$sym"} :
206 $type eq '*' ? *{"${pkg}::$sym"} :
207729µs do { require Carp; Carp::croak("Can't export symbol: $type$sym") };
208 }
209}
210
211sub heavy_export_to_level
212
# spent 456µs (34+422) within Exporter::Heavy::heavy_export_to_level which was called 2 times, avg 228µs/call: # 2 times (34µs+422µs) by Test::Builder::Module::import or Time::HiRes::import at line 82 of Exporter.pm, avg 228µs/call
{
21322µs my $pkg = shift;
2142900ns my $level = shift;
21522µs (undef) = shift; # XXX redundant arg
21623µs my $callpkg = caller($level);
217216µs230µs $pkg->export($callpkg, @_);
# spent 30µs making 2 calls to Exporter::export, avg 15µs/call
218}
219
220# Utility functions
221
222
# spent 20µs within Exporter::Heavy::_push_tags which was called 2 times, avg 10µs/call: # 2 times (20µs+0s) by Exporter::Heavy::heavy_export_ok_tags at line 248, avg 10µs/call
sub _push_tags {
22323µs my($pkg, $var, $syms) = @_;
22421µs my @nontag = ();
22524µs my $export_tags = \%{"${pkg}::EXPORT_TAGS"};
226 push(@{"${pkg}::$var"},
22728µs map { $export_tags->{$_} ? @{$export_tags->{$_}}
228 : scalar(push(@nontag,$_),$_) }
229 (@$syms) ? @$syms : keys %$export_tags);
23027µs if (@nontag and $^W) {
231 # This may change to a die one day
232 require Carp;
233 Carp::carp(join(", ", @nontag)." are not tags of $pkg");
234 }
235}
236
237sub heavy_require_version {
238 my($self, $wanted) = @_;
239 my $pkg = ref $self || $self;
240 return ${pkg}->VERSION($wanted);
241}
242
243sub heavy_export_tags {
244 _push_tags((caller)[0], "EXPORT", \@_);
245}
246
247
# spent 32µs (11+20) within Exporter::Heavy::heavy_export_ok_tags which was called 2 times, avg 16µs/call: # 2 times (11µs+20µs) by IO::Uncompress::Gunzip::BEGIN@12 or Net::HTTP::Methods::gunzip_ok at line 90 of Exporter.pm, avg 16µs/call
sub heavy_export_ok_tags {
248212µs220µs _push_tags((caller)[0], "EXPORT_OK", \@_);
# spent 20µs making 2 calls to Exporter::Heavy::_push_tags, avg 10µs/call
249}
250
251113µs1;
# spent 11µs within Exporter::Heavy::CORE:match which was called 17 times, avg 629ns/call: # 9 times (7µs+0s) by Exporter::Heavy::heavy_export at line 74 of Exporter/Heavy.pm, avg 778ns/call # 6 times (2µs+0s) by Exporter::Heavy::heavy_export at line 80 of Exporter/Heavy.pm, avg 383ns/call # 2 times (1µs+0s) by Exporter::Heavy::heavy_export at line 84 of Exporter/Heavy.pm, avg 700ns/call
sub Exporter::Heavy::CORE:match; # xsub
# spent 206µs within Exporter::Heavy::CORE:subst which was called 589 times, avg 350ns/call: # 535 times (193µs+0s) by Exporter::Heavy::heavy_export at line 197 of Exporter/Heavy.pm, avg 360ns/call # 38 times (4µs+0s) by Exporter::Heavy::_rebuild_cache at line 37 of Exporter/Heavy.pm, avg 116ns/call # 8 times (6µs+0s) by Exporter::Heavy::heavy_export at line 84 of Exporter/Heavy.pm, avg 762ns/call # 8 times (3µs+0s) by Exporter::Heavy::heavy_export at line 82 of Exporter/Heavy.pm, avg 362ns/call
sub Exporter::Heavy::CORE:subst; # xsub