← 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/ParserFactory.pm
StatementsExecuted 542 statements in 4.02ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
28223.03ms61.3msXML::SAX::ParserFactory::::parserXML::SAX::ParserFactory::parser
28111.11ms1.84msXML::SAX::ParserFactory::::_parser_classXML::SAX::ParserFactory::_parser_class
111757µs1.06msXML::SAX::ParserFactory::::BEGIN@12XML::SAX::ParserFactory::BEGIN@12
3011445µs445µsXML::SAX::ParserFactory::::CORE:openXML::SAX::ParserFactory::CORE:open (opcode)
422124µs808µsXML::SAX::ParserFactory::::newXML::SAX::ParserFactory::new
111122µs122µsXML::SAX::ParserFactory::::BEGIN@11XML::SAX::ParserFactory::BEGIN@11
281145µs45µsXML::SAX::ParserFactory::::CORE:substXML::SAX::ParserFactory::CORE:subst (opcode)
11116µs21µsXML::SAX::ParserFactory::::BEGIN@5XML::SAX::ParserFactory::BEGIN@5
11110µs67µsXML::SAX::ParserFactory::::BEGIN@10XML::SAX::ParserFactory::BEGIN@10
1118µs33µsXML::SAX::ParserFactory::::BEGIN@6XML::SAX::ParserFactory::BEGIN@6
1116µs6µsXML::SAX::ParserFactory::::require_featureXML::SAX::ParserFactory::require_feature
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1# $Id: ParserFactory.pm,v 1.14 2008-08-04 04:51:29 grant Exp $
2
3package XML::SAX::ParserFactory;
4
5329µs225µs
# spent 21µs (16+4) within XML::SAX::ParserFactory::BEGIN@5 which was called: # once (16µs+4µs) by XML::SAX::BEGIN@18 at line 5
use strict;
# spent 21µs making 1 call to XML::SAX::ParserFactory::BEGIN@5 # spent 4µs making 1 call to strict::import
6337µs258µs
# spent 33µs (8+25) within XML::SAX::ParserFactory::BEGIN@6 which was called: # once (8µs+25µs) by XML::SAX::BEGIN@18 at line 6
use vars qw($VERSION);
# spent 33µs making 1 call to XML::SAX::ParserFactory::BEGIN@6 # spent 25µs making 1 call to vars::import
7
81900ns$VERSION = '1.01';
9
103156µs2124µs
# spent 67µs (10+57) within XML::SAX::ParserFactory::BEGIN@10 which was called: # once (10µs+57µs) by XML::SAX::BEGIN@18 at line 10
use Symbol qw(gensym);
# spent 67µs making 1 call to XML::SAX::ParserFactory::BEGIN@10 # spent 57µs making 1 call to Exporter::import
11340µs1122µs
# spent 122µs within XML::SAX::ParserFactory::BEGIN@11 which was called: # once (122µs+0s) by XML::SAX::BEGIN@18 at line 11
use XML::SAX;
# spent 122µs making 1 call to XML::SAX::ParserFactory::BEGIN@11
123634µs11.06ms
# spent 1.06ms (757µs+299µs) within XML::SAX::ParserFactory::BEGIN@12 which was called: # once (757µs+299µs) by XML::SAX::BEGIN@18 at line 12
use XML::SAX::Exception;
# spent 1.06ms making 1 call to XML::SAX::ParserFactory::BEGIN@12
13
14
# spent 808µs (124+684) within XML::SAX::ParserFactory::new which was called 4 times, avg 202µs/call: # 3 times (98µs+679µs) by XML::SAX::ParserFactory::parser at line 25, avg 259µs/call # once (26µs+5µs) by C4::Biblio::BEGIN@29 at line 19 of MARC/File/XML.pm
sub new {
1547µs my $class = shift;
1649µs my %params = @_; # TODO : Fix this in spec.
17443µs my $self = bless \%params, $class;
18434µs4684µs $self->{KnownParsers} = XML::SAX->parsers();
# spent 684µs making 4 calls to XML::SAX::parsers, avg 171µs/call
19424µs return $self;
20}
21
22
# spent 61.3ms (3.03+58.2) within XML::SAX::ParserFactory::parser which was called 28 times, avg 2.19ms/call: # 25 times (979µs+2.97ms) by MARC::File::XML::decode at line 439 of MARC/File/XML.pm, avg 158µs/call # 3 times (2.05ms+55.3ms) by XML::Simple::build_tree at line 358 of XML/Simple.pm, avg 19.1ms/call
sub parser {
232836µs my $self = shift;
2428104µs my @parser_params = @_;
252857µs3777µs if (!ref($self)) {
# spent 777µs making 3 calls to XML::SAX::ParserFactory::new, avg 259µs/call
26 $self = $self->new();
27 }
28
2928146µs281.84ms my $parser_class = $self->_parser_class();
# spent 1.84ms making 28 calls to XML::SAX::ParserFactory::_parser_class, avg 66µs/call
30
312821µs my $version = '';
3228163µs2845µs if ($parser_class =~ s/\s*\(([\d\.]+)\)\s*$//) {
# spent 45µs making 28 calls to XML::SAX::ParserFactory::CORE:subst, avg 2µs/call
33 $version = " $1";
34 }
35
3628476µs28231µs if (!$parser_class->can('new')) {
# spent 231µs making 28 calls to UNIVERSAL::can, avg 8µs/call
37147µs eval "require $parser_class $version;";
# spent 123µs executing statements in string eval
381700ns die $@ if $@;
39 }
40
4128347µs282.31ms return $parser_class->new(@parser_params);
# spent 2.31ms making 28 calls to XML::SAX::Base::new, avg 82µs/call
42}
43
44
# spent 6µs within XML::SAX::ParserFactory::require_feature which was called: # once (6µs+0s) by C4::Biblio::BEGIN@29 at line 20 of MARC/File/XML.pm
sub require_feature {
451600ns my $self = shift;
4611µs my ($feature) = @_;
4712µs $self->{RequiredFeatures}{$feature}++;
48110µs return $self;
49}
50
51
# spent 1.84ms (1.11+731µs) within XML::SAX::ParserFactory::_parser_class which was called 28 times, avg 66µs/call: # 28 times (1.11ms+731µs) by XML::SAX::ParserFactory::parser at line 29, avg 66µs/call
sub _parser_class {
522834µs my $self = shift;
53
54 # First try ParserPackage
552826µs if ($XML::SAX::ParserPackage) {
56 return $XML::SAX::ParserPackage;
57 }
58
59 # Now check if required/preferred is there
602865µs if ($self->{RequiredFeatures}) {
6125152µs my %required = %{$self->{RequiredFeatures}};
62 # note - we never go onto the next try (ParserDetails.ini),
63 # because if we can't provide the requested feature
64 # we need to throw an exception.
65 PARSER:
662576µs foreach my $parser (reverse @{$self->{KnownParsers}}) {
672579µs foreach my $feature (keys %required) {
6825116µs if (!exists $parser->{Features}{$feature}) {
69 next PARSER;
70 }
71 }
72 # got here - all features must exist!
7325220µs return $parser->{Name};
74 }
75 # TODO : should this be NotSupported() ?
76 throw XML::SAX::Exception (
77 Message => "Unable to provide required features",
78 );
79 }
80
81 # Next try SAX.ini
8237µs for my $dir (@INC) {
833092µs30286µs my $fh = gensym();
# spent 286µs making 30 calls to Symbol::gensym, avg 10µs/call
8430700µs30445µs if (open($fh, "$dir/SAX.ini")) {
# spent 445µs making 30 calls to XML::SAX::ParserFactory::CORE:open, avg 15µs/call
85 my $param_list = XML::SAX->_parse_ini_file($fh);
86 my $params = $param_list->[0]->{Features};
87 if ($params->{ParserPackage}) {
88 return $params->{ParserPackage};
89 }
90 else {
91 # we have required features (or nothing?)
92 PARSER:
93 foreach my $parser (reverse @{$self->{KnownParsers}}) {
94 foreach my $feature (keys %$params) {
95 if (!exists $parser->{Features}{$feature}) {
96 next PARSER;
97 }
98 }
99 return $parser->{Name};
100 }
101 XML::SAX->do_warn("Unable to provide SAX.ini required features. Using fallback\n");
102 }
103 last; # stop after first INI found
104 }
105 }
106
107326µs if (@{$self->{KnownParsers}}) {
108 return $self->{KnownParsers}[-1]{Name};
109 }
110 else {
111 return "XML::SAX::PurePerl"; # backup plan!
112 }
113}
114
11513µs1;
116__END__
 
# spent 445µs within XML::SAX::ParserFactory::CORE:open which was called 30 times, avg 15µs/call: # 30 times (445µs+0s) by XML::SAX::ParserFactory::_parser_class at line 84, avg 15µs/call
sub XML::SAX::ParserFactory::CORE:open; # opcode
# spent 45µs within XML::SAX::ParserFactory::CORE:subst which was called 28 times, avg 2µs/call: # 28 times (45µs+0s) by XML::SAX::ParserFactory::parser at line 32, avg 2µs/call
sub XML::SAX::ParserFactory::CORE:subst; # opcode