← 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 17:10:45 2013
Reported on Tue Oct 15 17:12:37 2013

Filename/usr/share/perl5/XML/SAX/ParserFactory.pm
StatementsExecuted 428 statements in 2.73ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
25112.42ms12.1msXML::SAX::ParserFactory::::parserXML::SAX::ParserFactory::parser
2511674µs674µsXML::SAX::ParserFactory::::_parser_classXML::SAX::ParserFactory::_parser_class
251148µs48µsXML::SAX::ParserFactory::::CORE:substXML::SAX::ParserFactory::CORE:subst (opcode)
11129µs771µsXML::SAX::ParserFactory::::newXML::SAX::ParserFactory::new
11121µs26µsXML::SAX::ParserFactory::::BEGIN@5XML::SAX::ParserFactory::BEGIN@5
11120µs22µsXML::SAX::ParserFactory::::BEGIN@12XML::SAX::ParserFactory::BEGIN@12
11115µs17µsXML::SAX::ParserFactory::::BEGIN@11XML::SAX::ParserFactory::BEGIN@11
11110µs10µsXML::SAX::ParserFactory::::require_featureXML::SAX::ParserFactory::require_feature
11110µs76µsXML::SAX::ParserFactory::::BEGIN@10XML::SAX::ParserFactory::BEGIN@10
1119µs37µsXML::SAX::ParserFactory::::BEGIN@6XML::SAX::ParserFactory::BEGIN@6
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
5330µs230µs
# spent 26µs (21+4) within XML::SAX::ParserFactory::BEGIN@5 which was called: # once (21µs+4µs) by XML::SAX::BEGIN@18 at line 5
use strict;
# spent 26µs making 1 call to XML::SAX::ParserFactory::BEGIN@5 # spent 4µs making 1 call to strict::import
6342µs265µs
# spent 37µs (9+28) within XML::SAX::ParserFactory::BEGIN@6 which was called: # once (9µs+28µs) by XML::SAX::BEGIN@18 at line 6
use vars qw($VERSION);
# spent 37µs making 1 call to XML::SAX::ParserFactory::BEGIN@6 # spent 28µs making 1 call to vars::import
7
81700ns$VERSION = '1.01';
9
10337µs2142µs
# spent 76µs (10+66) within XML::SAX::ParserFactory::BEGIN@10 which was called: # once (10µs+66µs) by XML::SAX::BEGIN@18 at line 10
use Symbol qw(gensym);
# spent 76µs making 1 call to XML::SAX::ParserFactory::BEGIN@10 # spent 66µs making 1 call to Exporter::import
11331µs219µs
# spent 17µs (15+2) within XML::SAX::ParserFactory::BEGIN@11 which was called: # once (15µs+2µs) by XML::SAX::BEGIN@18 at line 11
use XML::SAX;
# spent 17µs making 1 call to XML::SAX::ParserFactory::BEGIN@11 # spent 2µs making 1 call to UNIVERSAL::import
123588µs223µs
# spent 22µs (20+1) within XML::SAX::ParserFactory::BEGIN@12 which was called: # once (20µs+1µs) by XML::SAX::BEGIN@18 at line 12
use XML::SAX::Exception;
# spent 22µs making 1 call to XML::SAX::ParserFactory::BEGIN@12 # spent 2µs making 1 call to UNIVERSAL::import
13
14
# spent 771µs (29+741) within XML::SAX::ParserFactory::new which was called: # once (29µs+741µs) by C4::Biblio::BEGIN@29 at line 19 of MARC/File/XML.pm
sub new {
1512µs my $class = shift;
1612µs my %params = @_; # TODO : Fix this in spec.
17112µs my $self = bless \%params, $class;
1816µs1741µs $self->{KnownParsers} = XML::SAX->parsers();
# spent 741µs making 1 call to XML::SAX::parsers
1915µs return $self;
20}
21
22
# spent 12.1ms (2.42+9.68) within XML::SAX::ParserFactory::parser which was called 25 times, avg 484µs/call: # 25 times (2.42ms+9.68ms) by MARC::File::XML::decode at line 439 of MARC/File/XML.pm, avg 484µs/call
sub parser {
232520µs my $self = shift;
242584µs my @parser_params = @_;
252531µs if (!ref($self)) {
26 $self = $self->new();
27 }
28
2925125µs25674µs my $parser_class = $self->_parser_class();
# spent 674µs making 25 calls to XML::SAX::ParserFactory::_parser_class, avg 27µs/call
30
312525µs my $version = '';
3225169µs2548µs if ($parser_class =~ s/\s*\(([\d\.]+)\)\s*$//) {
# spent 48µs making 25 calls to XML::SAX::ParserFactory::CORE:subst, avg 2µs/call
33 $version = " $1";
34 }
35
3625449µs25230µs if (!$parser_class->can('new')) {
# spent 230µs making 25 calls to UNIVERSAL::can, avg 9µs/call
37152µs eval "require $parser_class $version;";
# spent 169µs executing statements in string eval
381700ns die $@ if $@;
39 }
40
4125257µs252.00ms return $parser_class->new(@parser_params);
# spent 2.00ms making 25 calls to XML::SAX::Base::new, avg 80µs/call
42}
43
44
# spent 10µs within XML::SAX::ParserFactory::require_feature which was called: # once (10µs+0s) by C4::Biblio::BEGIN@29 at line 20 of MARC/File/XML.pm
sub require_feature {
4511µs my $self = shift;
4612µs my ($feature) = @_;
4713µs $self->{RequiredFeatures}{$feature}++;
48113µs return $self;
49}
50
51
# spent 674µs within XML::SAX::ParserFactory::_parser_class which was called 25 times, avg 27µs/call: # 25 times (674µs+0s) by XML::SAX::ParserFactory::parser at line 29, avg 27µs/call
sub _parser_class {
522525µs my $self = shift;
53
54 # First try ParserPackage
552527µs if ($XML::SAX::ParserPackage) {
56 return $XML::SAX::ParserPackage;
57 }
58
59 # Now check if required/preferred is there
602548µs if ($self->{RequiredFeatures}) {
6125153µ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}}) {
672569µs foreach my $feature (keys %required) {
6825101µs if (!exists $parser->{Features}{$feature}) {
69 next PARSER;
70 }
71 }
72 # got here - all features must exist!
7325242µ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
82 for my $dir (@INC) {
83 my $fh = gensym();
84 if (open($fh, "$dir/SAX.ini")) {
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
107 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 48µs within XML::SAX::ParserFactory::CORE:subst which was called 25 times, avg 2µs/call: # 25 times (48µs+0s) by XML::SAX::ParserFactory::parser at line 32, avg 2µs/call
sub XML::SAX::ParserFactory::CORE:subst; # opcode