← 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:53 2013

Filename/usr/share/perl5/XML/SAX.pm
StatementsExecuted 153 statements in 2.10ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
111727µs2.03msXML::SAX::::BEGIN@18XML::SAX::BEGIN@18
111160µs266µsXML::SAX::::_parse_ini_fileXML::SAX::_parse_ini_file
11175µs655µsXML::SAX::::load_parsersXML::SAX::load_parsers
11164µs64µsXML::SAX::::CORE:openXML::SAX::CORE:open (opcode)
363151µs51µsXML::SAX::::CORE:substXML::SAX::CORE:subst (opcode)
212131µs31µsXML::SAX::::CORE:matchXML::SAX::CORE:match (opcode)
41129µs684µsXML::SAX::::parsersXML::SAX::parsers
131125µs25µsXML::SAX::::CORE:readlineXML::SAX::CORE:readline (opcode)
11121µs27µsXML::SAX::::BEGIN@5XML::SAX::BEGIN@5
11120µs106µsXML::SAX::::BEGIN@15XML::SAX::BEGIN@15
11115µs78µsXML::SAX::::BEGIN@17XML::SAX::BEGIN@17
11113µs82µsXML::SAX::::BEGIN@20XML::SAX::BEGIN@20
11111µs84µsXML::SAX::::BEGIN@6XML::SAX::BEGIN@6
1119µs41µsXML::SAX::::BEGIN@23XML::SAX::BEGIN@23
1119µs84µsXML::SAX::::BEGIN@22XML::SAX::BEGIN@22
1116µs6µsXML::SAX::::BEGIN@10XML::SAX::BEGIN@10
1116µs6µsXML::SAX::::BEGIN@16XML::SAX::BEGIN@16
0000s0sXML::SAX::::_is_vendor_suppliedXML::SAX::_is_vendor_supplied
0000s0sXML::SAX::::add_parserXML::SAX::add_parser
0000s0sXML::SAX::::do_warnXML::SAX::do_warn
0000s0sXML::SAX::::remove_parserXML::SAX::remove_parser
0000s0sXML::SAX::::save_parsersXML::SAX::save_parsers
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1# $Id: SAX.pm,v 1.31 2008-08-05 12:36:24 grant Exp $
2
3package XML::SAX;
4
5337µs233µs
# spent 27µs (21+6) within XML::SAX::BEGIN@5 which was called: # once (21µs+6µs) by XML::Simple::build_tree at line 5
use strict;
# spent 27µs making 1 call to XML::SAX::BEGIN@5 # spent 6µs making 1 call to strict::import
6342µs2156µs
# spent 84µs (11+73) within XML::SAX::BEGIN@6 which was called: # once (11µs+73µs) by XML::Simple::build_tree at line 6
use vars qw($VERSION @ISA @EXPORT_OK);
# spent 84µs making 1 call to XML::SAX::BEGIN@6 # spent 72µs making 1 call to vars::import
7
812µs$VERSION = '0.96';
9
10342µs16µs
# spent 6µs within XML::SAX::BEGIN@10 which was called: # once (6µs+0s) by XML::Simple::build_tree at line 10
use Exporter ();
# spent 6µs making 1 call to XML::SAX::BEGIN@10
11124µs@ISA = ('Exporter');
12
1311µs@EXPORT_OK = qw(Namespaces Validation);
14
15336µs2192µs
# spent 106µs (20+86) within XML::SAX::BEGIN@15 which was called: # once (20µs+86µs) by XML::Simple::build_tree at line 15
use File::Basename qw(dirname);
# spent 106µs making 1 call to XML::SAX::BEGIN@15 # spent 86µs making 1 call to Exporter::import
16325µs16µs
# spent 6µs within XML::SAX::BEGIN@16 which was called: # once (6µs+0s) by XML::Simple::build_tree at line 16
use File::Spec ();
# spent 6µs making 1 call to XML::SAX::BEGIN@16
17335µs2141µs
# spent 78µs (15+63) within XML::SAX::BEGIN@17 which was called: # once (15µs+63µs) by XML::Simple::build_tree at line 17
use Symbol qw(gensym);
# spent 78µs making 1 call to XML::SAX::BEGIN@17 # spent 63µs making 1 call to Exporter::import
183134µs12.03ms
# spent 2.03ms (727µs+1.30) within XML::SAX::BEGIN@18 which was called: # once (727µs+1.30ms) by XML::Simple::build_tree at line 18
use XML::SAX::ParserFactory (); # loaded for simplicity
# spent 2.03ms making 1 call to XML::SAX::BEGIN@18
19
20336µs2150µs
# spent 82µs (13+69) within XML::SAX::BEGIN@20 which was called: # once (13µs+69µs) by XML::Simple::build_tree at line 20
use constant PARSER_DETAILS => "ParserDetails.ini";
# spent 82µs making 1 call to XML::SAX::BEGIN@20 # spent 69µs making 1 call to constant::import
21
22335µs2159µs
# spent 84µs (9+75) within XML::SAX::BEGIN@22 which was called: # once (9µs+75µs) by XML::Simple::build_tree at line 22
use constant Namespaces => "http://xml.org/sax/features/namespaces";
# spent 84µs making 1 call to XML::SAX::BEGIN@22 # spent 75µs making 1 call to constant::import
2331.19ms273µs
# spent 41µs (9+32) within XML::SAX::BEGIN@23 which was called: # once (9µs+32µs) by XML::Simple::build_tree at line 23
use constant Validation => "http://xml.org/sax/features/validation";
# spent 41µs making 1 call to XML::SAX::BEGIN@23 # spent 32µs making 1 call to constant::import
24
2511µsmy $known_parsers = undef;
26
27# load_parsers takes the ParserDetails.ini file out of the same directory
28# that XML::SAX is in, and looks at it. Format in POD below
29
30=begin EXAMPLE
31
- -
47
# spent 655µs (75+579) within XML::SAX::load_parsers which was called: # once (75µs+579µs) by XML::SAX::parsers at line 114
sub load_parsers {
4811µs my $class = shift;
491500ns my $dir = shift;
50
51 # reset parsers
5212µs $known_parsers = [];
53
54 # get directory from wherever XML::SAX is installed
5511µs if (!$dir) {
5613µs $dir = $INC{'XML/SAX.pm'};
5716µs1135µs $dir = dirname($dir);
# spent 135µs making 1 call to File::Basename::dirname
58 }
59
6015µs118µs my $fh = gensym();
# spent 18µs making 1 call to Symbol::gensym
61185µs2159µs if (!open($fh, File::Spec->catfile($dir, "SAX", PARSER_DETAILS))) {
# spent 96µs making 1 call to File::Spec::Unix::catfile # spent 64µs making 1 call to XML::SAX::CORE:open
62 XML::SAX->do_warn("could not find " . PARSER_DETAILS . " in $dir/SAX\n");
63 return $class;
64 }
65
6615µs1266µs $known_parsers = $class->_parse_ini_file($fh);
# spent 266µs making 1 call to XML::SAX::_parse_ini_file
67
68128µs return $class;
69}
70
71
# spent 266µs (160+107) within XML::SAX::_parse_ini_file which was called: # once (160µs+107µs) by XML::SAX::load_parsers at line 66
sub _parse_ini_file {
7211µs my $class = shift;
731900ns my ($fh) = @_;
74
751300ns my @config;
76
771700ns my $lineno = 0;
78154µs1325µs while (defined(my $line = <$fh>)) {
# spent 25µs making 13 calls to XML::SAX::CORE:readline, avg 2µs/call
79123µs $lineno++;
80125µs my $original = $line;
81 # strip whitespace
821258µs1236µs $line =~ s/\s*$//m;
# spent 36µs making 12 calls to XML::SAX::CORE:subst, avg 3µs/call
831226µs128µs $line =~ s/^\s*//m;
# spent 8µs making 12 calls to XML::SAX::CORE:subst, avg 658ns/call
84 # strip comments
851222µs126µs $line =~ s/[#;].*$//m;
# spent 6µs making 12 calls to XML::SAX::CORE:subst, avg 542ns/call
86 # ignore blanks
871231µs127µs next if $line =~ /^$/m;
# spent 7µs making 12 calls to XML::SAX::CORE:match, avg 617ns/call
88
89 # heading
90639µs923µs if ($line =~ /^\[\s*(.*)\s*\]$/m) {
# spent 23µs making 9 calls to XML::SAX::CORE:match, avg 3µs/call
9138µs push @config, { Name => $1 };
9233µs next;
93 }
94
95 # instruction
96 elsif ($line =~ /^(.*?)\s*?=\s*(.*)$/) {
9732µs unless(@config) {
98 push @config, { Name => '' };
99 }
100310µs $config[-1]{Features}{$1} = $2;
101 }
102
103 # not whitespace, comment, or instruction
104 else {
105 die "Invalid line in ini: $lineno\n>>> $original\n";
106 }
107 }
108
10915µs return \@config;
110}
111
112
# spent 684µs (29+655) within XML::SAX::parsers which was called 4 times, avg 171µs/call: # 4 times (29µs+655µs) by XML::SAX::ParserFactory::new at line 18 of XML/SAX/ParserFactory.pm, avg 171µs/call
sub parsers {
11345µs my $class = shift;
11447µs1655µs if (!$known_parsers) {
# spent 655µs making 1 call to XML::SAX::load_parsers
115 $class->load_parsers();
116 }
117429µs return $known_parsers;
118}
119
120sub remove_parser {
121 my $class = shift;
122 my ($parser_module) = @_;
123
124 if (!$known_parsers) {
125 $class->load_parsers();
126 }
127
128 @$known_parsers = grep { $_->{Name} ne $parser_module } @$known_parsers;
129
130 return $class;
131}
132
133sub add_parser {
134 my $class = shift;
135 my ($parser_module) = @_;
136
137 if (!$known_parsers) {
138 $class->load_parsers();
139 }
140
141 # first load module, then query features, then push onto known_parsers,
142
143 my $parser_file = $parser_module;
144 $parser_file =~ s/::/\//g;
145 $parser_file .= ".pm";
146
147 require $parser_file;
148
149 my @features = $parser_module->supported_features();
150
151 my $new = { Name => $parser_module };
152 foreach my $feature (@features) {
153 $new->{Features}{$feature} = 1;
154 }
155
156 # If exists in list already, move to end.
157 my $done = 0;
158 my $pos = undef;
159 for (my $i = 0; $i < @$known_parsers; $i++) {
160 my $p = $known_parsers->[$i];
161 if ($p->{Name} eq $parser_module) {
162 $pos = $i;
163 }
164 }
165 if (defined $pos) {
166 splice(@$known_parsers, $pos, 1);
167 push @$known_parsers, $new;
168 $done++;
169 }
170
171 # Otherwise (not in list), add at end of list.
172 if (!$done) {
173 push @$known_parsers, $new;
174 }
175
176 return $class;
177}
178
179sub save_parsers {
180 my $class = shift;
181
182 ### DEBIAN MODIFICATION
183 print "\n";
184 print "Please use 'update-perl-sax-parsers(8) to register this parser.'\n";
185 print "See /usr/share/doc/libxml-sax-perl/README.Debian.gz for more info.\n";
186 print "\n";
187
188 return $class; # rest of the function is disabled on Debian.
189 ### END DEBIAN MODIFICATION
190
191 # get directory from wherever XML::SAX is installed
192 my $dir = $INC{'XML/SAX.pm'};
193 $dir = dirname($dir);
194
195 my $file = File::Spec->catfile($dir, "SAX", PARSER_DETAILS);
196 chmod 0644, $file;
197 unlink($file);
198
199 my $fh = gensym();
200 open($fh, ">$file") ||
201 die "Cannot write to $file: $!";
202
203 foreach my $p (@$known_parsers) {
204 print $fh "[$p->{Name}]\n";
205 foreach my $key (keys %{$p->{Features}}) {
206 print $fh "$key = $p->{Features}{$key}\n";
207 }
208 print $fh "\n";
209 }
210
211 print $fh "\n";
212
213 close $fh;
214
215 return $class;
216}
217
218sub do_warn {
219 my $class = shift;
220 # Don't output warnings if running under Test::Harness
221 warn(@_) unless $ENV{HARNESS_ACTIVE};
222}
223
224sub _is_vendor_supplied {
225 1;
226}
227
228112µs1;
229__END__
 
# spent 31µs within XML::SAX::CORE:match which was called 21 times, avg 1µs/call: # 12 times (7µs+0s) by XML::SAX::_parse_ini_file at line 87, avg 617ns/call # 9 times (23µs+0s) by XML::SAX::_parse_ini_file at line 90, avg 3µs/call
sub XML::SAX::CORE:match; # opcode
# spent 64µs within XML::SAX::CORE:open which was called: # once (64µs+0s) by XML::SAX::load_parsers at line 61
sub XML::SAX::CORE:open; # opcode
# spent 25µs within XML::SAX::CORE:readline which was called 13 times, avg 2µs/call: # 13 times (25µs+0s) by XML::SAX::_parse_ini_file at line 78, avg 2µs/call
sub XML::SAX::CORE:readline; # opcode
# spent 51µs within XML::SAX::CORE:subst which was called 36 times, avg 1µs/call: # 12 times (36µs+0s) by XML::SAX::_parse_ini_file at line 82, avg 3µs/call # 12 times (8µs+0s) by XML::SAX::_parse_ini_file at line 83, avg 658ns/call # 12 times (6µs+0s) by XML::SAX::_parse_ini_file at line 85, avg 542ns/call
sub XML::SAX::CORE:subst; # opcode