← Index
NYTProf Performance Profile   « block view • line view • sub view »
For /usr/share/koha/opac/cgi-bin/opac/opac-search.pl
  Run on Tue Oct 15 11:58:52 2013
Reported on Tue Oct 15 12:01:10 2013

Filename/usr/share/perl/5.10/Exporter/Heavy.pm
StatementsExecuted 7060 statements in 35.3ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
981129.0ms32.9msExporter::Heavy::::heavy_exportExporter::Heavy::heavy_export
3518613.49ms3.49msExporter::Heavy::::CORE:substExporter::Heavy::CORE:subst (opcode)
311323µs361µsExporter::Heavy::::_rebuild_cacheExporter::Heavy::_rebuild_cache
1111194µs3.04msExporter::Heavy::::heavy_export_to_levelExporter::Heavy::heavy_export_to_level
11180µs80µsExporter::Heavy::::_push_tagsExporter::Heavy::_push_tags
11178µs158µsExporter::Heavy::::heavy_export_ok_tagsExporter::Heavy::heavy_export_ok_tags
544173µs73µsExporter::Heavy::::CORE:matchExporter::Heavy::CORE:match (opcode)
11120µs25µsExporter::Heavy::::BEGIN@3Exporter::Heavy::BEGIN@3
11116µs40µsExporter::Heavy::::BEGIN@186Exporter::Heavy::BEGIN@186
11112µs30µsExporter::Heavy::::BEGIN@4Exporter::Heavy::BEGIN@4
0000s0sExporter::Heavy::::__ANON__[:41]Exporter::Heavy::__ANON__[:41]
0000s0sExporter::Heavy::::__ANON__[:47]Exporter::Heavy::__ANON__[:47]
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
3373µs231µs
# spent 25µs (20+6) within Exporter::Heavy::BEGIN@3 which was called: # once (20µs+6µs) by Exporter::as_heavy at line 3
use strict;
# spent 25µs making 1 call to Exporter::Heavy::BEGIN@3 # spent 6µs making 1 call to strict::import
431.15ms249µs
# spent 30µs (12+18) within Exporter::Heavy::BEGIN@4 which was called: # once (12µs+18µs) by Exporter::as_heavy at line 4
no strict 'refs';
# spent 30µs making 1 call to Exporter::Heavy::BEGIN@4 # spent 18µs making 1 call to strict::unimport
5
6# On one line so MakeMaker will see it.
722µ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
1011µs$Carp::Internal{'Exporter::Heavy'}++;
11
12#
13# We go to a lot of trouble not to 'require Carp' at file scope,
14# because Carp requires Exporter, and something has to give.
15#
16
17
# spent 361µs (323+39) within Exporter::Heavy::_rebuild_cache which was called 3 times, avg 120µs/call: # 3 times (323µs+39µs) by Exporter::Heavy::heavy_export at line 56, avg 120µs/call
sub _rebuild_cache {
1818270µs my ($pkg, $exports, $cache) = @_;
199330µs s/^&// foreach @$exports;
# spent 30µs making 93 calls to Exporter::Heavy::CORE:subst, avg 318ns/call
20 @{$cache}{@$exports} = (1) x @$exports;
21 my $ok = \@{"${pkg}::EXPORT_OK"};
22697µs if (@$ok) {
23259µs s/^&// foreach @$ok;
# spent 9µs making 25 calls to Exporter::Heavy::CORE:subst, avg 356ns/call
24 @{$cache}{@$ok} = (1) x @$ok;
25 }
26}
27
28
# spent 32.9ms (29.0+3.89) within Exporter::Heavy::heavy_export which was called 98 times, avg 335µs/call: # 98 times (29.0ms+3.89ms) by Exporter::Heavy::heavy_export_to_level or Exporter::import or FileHandle::import or IO::Socket::import or LWP::Simple::import at line 28 of Exporter.pm, avg 335µs/call
sub heavy_export {
29
30 # First make import warnings look like they're coming from the "use".
31 local $SIG{__WARN__} = sub {
32 my $text = shift;
33 if ($text =~ s/ at \S*Exporter\S*.pm line \d+.*\n//) {
34 require Carp;
35 local $Carp::CarpLevel = 1; # ignore package calling us too.
36 Carp::carp($text);
37 }
38 else {
39 warn $text;
40 }
419804.68ms };
42 local $SIG{__DIE__} = sub {
43 require Carp;
44 local $Carp::CarpLevel = 1; # ignore package calling us too.
45 Carp::croak("$_[0]Illegal null symbol in \@${1}::EXPORT")
46 if $_[0] =~ /^Unable to create sub named "(.*?)::"/;
47 };
48
49 my($pkg, $callpkg, @imports) = @_;
50 my($type, $sym, $cache_is_current, $oops);
51 my($exports, $export_cache) = (\@{"${pkg}::EXPORT"},
52 $Exporter::Cache{$pkg} ||= {});
53
541861.44ms if (@imports) {
55612µs if (!%$export_cache) {
563361µs _rebuild_cache ($pkg, $exports, $export_cache);
# spent 361µs making 3 calls to Exporter::Heavy::_rebuild_cache, avg 120µs/call
57 $cache_is_current = 1;
58 }
59
60133461µs2948µs if (grep m{^[/!:]}, @imports) {
# spent 48µs making 29 calls to Exporter::Heavy::CORE:match, avg 2µs/call
61 my $tagsref = \%{"${pkg}::EXPORT_TAGS"};
62 my $tagdata;
63 my %imports;
64 my($remove, $spec, @names, @allexports);
65 # negated first item implies starting with default set:
661915µs unshift @imports, ':DEFAULT' if $imports[0] =~ m/^!/;
# spent 15µs making 19 calls to Exporter::Heavy::CORE:match, avg 795ns/call
67 foreach $spec (@imports){
6892511µs2321µs $remove = $spec =~ s/^!//;
# spent 21µs making 23 calls to Exporter::Heavy::CORE:subst, avg 909ns/call
69
7023219µs25241µs if ($spec =~ s/^://){
# spent 239µs making 23 calls to Exporter::Heavy::CORE:subst, avg 10µs/call # spent 2µs making 2 calls to Exporter::Heavy::CORE:match, avg 850ns/call
71 if ($spec eq 'DEFAULT'){
72 @names = @$exports;
73 }
74 elsif ($tagdata = $tagsref->{$spec}) {
75 @names = @$tagdata;
76 }
77 else {
78 warn qq["$spec" is not defined in %${pkg}::EXPORT_TAGS];
79 ++$oops;
80 next;
81 }
82 }
83 elsif ($spec =~ m:^/(.*)/$:){
84 my $patn = $1;
85 @allexports = keys %$export_cache unless @allexports; # only do keys once
86 @names = grep(/$patn/, @allexports); # not anchored by default
87 }
88 else {
89 @names = ($spec); # is a normal symbol name
90 }
91
92 warn "Import ".($remove ? "del":"add").": @names "
93 if $Exporter::Verbose;
94
9523222µs if ($remove) {
96 foreach $sym (@names) { delete $imports{$sym} }
97 }
98 else {
99 @imports{@names} = (1) x @names;
100 }
101 }
102 @imports = keys %imports;
103 }
104
105 my @carp;
106 foreach $sym (@imports) {
107377326µs if (!$export_cache->{$sym}) {
108816µs if ($sym =~ m/^\d/) {
# spent 8µs making 4 calls to Exporter::Heavy::CORE:subst, avg 2µs/call # spent 8µs making 4 calls to Exporter::Heavy::CORE:match, avg 2µs/call
109 $pkg->VERSION($sym); # inherit from UNIVERSAL
110 # If the version number was the only thing specified
111 # then we should act as if nothing was specified:
112 if (@imports == 1) {
113 @imports = @$exports;
114 last;
115 }
116 # We need a way to emulate 'use Foo ()' but still
117 # allow an easy version check: "use Foo 1.23, ''";
118 if (@imports == 2 and !$imports[1]) {
119 @imports = ();
120 last;
121 }
122 } elsif ($sym !~ s/^&// || !$export_cache->{$sym}) {
123 # Last chance - see if they've updated EXPORT_OK since we
124 # cached it.
125
126 unless ($cache_is_current) {
127 %$export_cache = ();
128 _rebuild_cache ($pkg, $exports, $export_cache);
129 $cache_is_current = 1;
130 }
131
132 if (!$export_cache->{$sym}) {
133 # accumulate the non-exports
134 push @carp,
135 qq["$sym" is not exported by the $pkg module\n];
136 $oops++;
137 }
138 }
139 }
140 }
141 if ($oops) {
142 require Carp;
143 Carp::croak("@{carp}Can't continue after import errors");
144 }
145 }
146 else {
147 @imports = @$exports;
148 }
149
150 my($fail, $fail_cache) = (\@{"${pkg}::EXPORT_FAIL"},
151 $Exporter::FailCache{$pkg} ||= {});
152
153 if (@$fail) {
154 if (!%$fail_cache) {
155 # Build cache of symbols. Optimise the lookup by adding
156 # barewords twice... both with and without a leading &.
157 # (Technique could be applied to $export_cache at cost of memory)
158 my @expanded = map { /^\w/ ? ($_, '&'.$_) : $_ } @$fail;
159 warn "${pkg}::EXPORT_FAIL cached: @expanded" if $Exporter::Verbose;
160 @{$fail_cache}{@expanded} = (1) x @expanded;
161 }
162 my @failed;
163 foreach $sym (@imports) { push(@failed, $sym) if $fail_cache->{$sym} }
164 if (@failed) {
165 @failed = $pkg->export_fail(@failed);
166 foreach $sym (@failed) {
167 require Carp;
168 Carp::carp(qq["$sym" is not implemented by the $pkg module ],
169 "on this architecture");
170 }
171 if (@failed) {
172 require Carp;
173 Carp::croak("Can't continue after import errors");
174 }
175 }
176 }
177
178 warn "Importing into $callpkg from $pkg: ",
179 join(", ",sort @imports) if $Exporter::Verbose;
180
181 foreach $sym (@imports) {
182 # shortcut for the common case of no type character
183514224.9ms33503.19ms (*{"${callpkg}::$sym"} = \&{"${pkg}::$sym"}, next)
# spent 3.19ms making 3350 calls to Exporter::Heavy::CORE:subst, avg 951ns/call
184 unless $sym =~ s/^(\W)//;
185 $type = $1;
1863619µs265µs
# spent 40µs (16+25) within Exporter::Heavy::BEGIN@186 which was called: # once (16µs+25µs) by Exporter::as_heavy at line 186
no warnings 'once';
# spent 40µs making 1 call to Exporter::Heavy::BEGIN@186 # spent 25µs making 1 call to warnings::unimport
187 *{"${callpkg}::$sym"} =
188 $type eq '&' ? \&{"${pkg}::$sym"} :
189 $type eq '$' ? \${"${pkg}::$sym"} :
190 $type eq '@' ? \@{"${pkg}::$sym"} :
191 $type eq '%' ? \%{"${pkg}::$sym"} :
192 $type eq '*' ? *{"${pkg}::$sym"} :
193 do { require Carp; Carp::croak("Can't export symbol: $type$sym") };
194 }
195}
196
197sub heavy_export_to_level
198
# spent 3.04ms (194µs+2.85) within Exporter::Heavy::heavy_export_to_level which was called 11 times, avg 277µs/call: # 11 times (194µs+2.85ms) by JSON::import or XML::LibXML::import at line 82 of Exporter.pm, avg 277µs/call
{
19955146µs my $pkg = shift;
200 my $level = shift;
201 (undef) = shift; # XXX redundant arg
202 my $callpkg = caller($level);
20311200µs $pkg->export($callpkg, @_);
# spent 200µs making 11 calls to Exporter::export, avg 18µs/call
204}
205
206# Utility functions
207
208
# spent 80µs within Exporter::Heavy::_push_tags which was called: # once (80µs+0s) by Exporter::Heavy::heavy_export_ok_tags at line 234
sub _push_tags {
2095153µs my($pkg, $var, $syms) = @_;
210 my @nontag = ();
211 my $export_tags = \%{"${pkg}::EXPORT_TAGS"};
212 push(@{"${pkg}::$var"},
213 map { $export_tags->{$_} ? @{$export_tags->{$_}}
214 : scalar(push(@nontag,$_),$_) }
215 (@$syms) ? @$syms : keys %$export_tags);
216 if (@nontag and $^W) {
217 # This may change to a die one day
218 require Carp;
219 Carp::carp(join(", ", @nontag)." are not tags of $pkg");
220 }
221}
222
223sub heavy_require_version {
224 my($self, $wanted) = @_;
225 my $pkg = ref $self || $self;
226 return ${pkg}->VERSION($wanted);
227}
228
229sub heavy_export_tags {
230 _push_tags((caller)[0], "EXPORT", \@_);
231}
232
233
# spent 158µs (78+80) within Exporter::Heavy::heavy_export_ok_tags which was called: # once (78µs+80µs) by DBI::BEGIN@160 at line 90 of Exporter.pm
sub heavy_export_ok_tags {
23417µs180µs _push_tags((caller)[0], "EXPORT_OK", \@_);
# spent 80µs making 1 call to Exporter::Heavy::_push_tags
235}
236
23714µs1;
 
# spent 73µs within Exporter::Heavy::CORE:match which was called 54 times, avg 1µs/call: # 29 times (48µs+0s) by Exporter::Heavy::heavy_export at line 60, avg 2µs/call # 19 times (15µs+0s) by Exporter::Heavy::heavy_export at line 66, avg 795ns/call # 4 times (8µs+0s) by Exporter::Heavy::heavy_export at line 108, avg 2µs/call # 2 times (2µs+0s) by Exporter::Heavy::heavy_export at line 70, avg 850ns/call
sub Exporter::Heavy::CORE:match; # opcode
# spent 3.49ms within Exporter::Heavy::CORE:subst which was called 3518 times, avg 993ns/call: # 3350 times (3.19ms+0s) by Exporter::Heavy::heavy_export at line 183, avg 951ns/call # 93 times (30µs+0s) by Exporter::Heavy::_rebuild_cache at line 19, avg 318ns/call # 25 times (9µs+0s) by Exporter::Heavy::_rebuild_cache at line 23, avg 356ns/call # 23 times (239µs+0s) by Exporter::Heavy::heavy_export at line 70, avg 10µs/call # 23 times (21µs+0s) by Exporter::Heavy::heavy_export at line 68, avg 909ns/call # 4 times (8µs+0s) by Exporter::Heavy::heavy_export at line 108, avg 2µs/call
sub Exporter::Heavy::CORE:subst; # opcode