← Index
NYTProf Performance Profile   « block view • line view • sub view »
For conv.pl
  Run on Sun Nov 14 21:27:43 2010
Reported on Sun Nov 14 21:29:12 2010

Filename/usr/share/perl5/XML/SAX/ParserFactory.pm
StatementsExecuted 85030 statements in 264ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
500011156ms696msXML::SAX::ParserFactory::::parserXML::SAX::ParserFactory::parser
50001198.6ms98.6msXML::SAX::ParserFactory::::_parser_classXML::SAX::ParserFactory::_parser_class
5000118.52ms8.52msXML::SAX::ParserFactory::::CORE:substXML::SAX::ParserFactory::CORE:subst (opcode)
111774µs2.68msXML::SAX::ParserFactory::::BEGIN@12XML::SAX::ParserFactory::BEGIN@12
11136µs2.00msXML::SAX::ParserFactory::::newXML::SAX::ParserFactory::new
11124µs31µsXML::SAX::ParserFactory::::BEGIN@5XML::SAX::ParserFactory::BEGIN@5
11117µs56µsXML::SAX::ParserFactory::::BEGIN@6XML::SAX::ParserFactory::BEGIN@6
11115µs15µsXML::SAX::ParserFactory::::BEGIN@11XML::SAX::ParserFactory::BEGIN@11
11115µs68µsXML::SAX::ParserFactory::::BEGIN@10XML::SAX::ParserFactory::BEGIN@10
11115µs41µsXML::SAX::ParserFactory::::BEGIN@37XML::SAX::ParserFactory::BEGIN@37
11114µs14µ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.13 2002/11/19 18:25:47 matt Exp $
2
3package XML::SAX::ParserFactory;
4
5346µs238µs
# spent 31µs (24+7) within XML::SAX::ParserFactory::BEGIN@5 which was called: # once (24µs+7µs) by XML::SAX::BEGIN@18 at line 5
use strict;
# spent 31µs making 1 call to XML::SAX::ParserFactory::BEGIN@5 # spent 7µs making 1 call to strict::import
6356µs295µs
# spent 56µs (17+39) within XML::SAX::ParserFactory::BEGIN@6 which was called: # once (17µs+39µs) by XML::SAX::BEGIN@18 at line 6
use vars qw($VERSION);
# spent 56µs making 1 call to XML::SAX::ParserFactory::BEGIN@6 # spent 39µs making 1 call to vars::import
7
812µs$VERSION = '1.01';
9
10341µs2121µs
# spent 68µs (15+53) within XML::SAX::ParserFactory::BEGIN@10 which was called: # once (15µs+53µs) by XML::SAX::BEGIN@18 at line 10
use Symbol qw(gensym);
# spent 68µs making 1 call to XML::SAX::ParserFactory::BEGIN@10 # spent 53µs making 1 call to Exporter::import
11342µs115µs
# spent 15µs within XML::SAX::ParserFactory::BEGIN@11 which was called: # once (15µs+0s) by XML::SAX::BEGIN@18 at line 11
use XML::SAX;
# spent 15µs making 1 call to XML::SAX::ParserFactory::BEGIN@11
123314µs12.68ms
# spent 2.68ms (774µs+1.91) within XML::SAX::ParserFactory::BEGIN@12 which was called: # once (774µs+1.91ms) by XML::SAX::BEGIN@18 at line 12
use XML::SAX::Exception;
# spent 2.68ms making 1 call to XML::SAX::ParserFactory::BEGIN@12
13
14
# spent 2.00ms (36µs+1.97) within XML::SAX::ParserFactory::new which was called: # once (36µs+1.97ms) by main::BEGIN@3 at line 19 of MARC/File/XML.pm
sub new {
1512µs my $class = shift;
1612µs my %params = @_; # TODO : Fix this in spec.
17111µs my $self = bless \%params, $class;
1818µs11.97ms $self->{KnownParsers} = XML::SAX->parsers();
# spent 1.97ms making 1 call to XML::SAX::parsers
1917µs return $self;
20}
21
22
# spent 696ms (156+540) within XML::SAX::ParserFactory::parser which was called 5000 times, avg 139µs/call: # 5000 times (156ms+540ms) by MARC::File::XML::decode at line 439 of MARC/File/XML.pm, avg 139µs/call
sub parser {
2350005.88ms my $self = shift;
24500016.8ms my @parser_params = @_;
2550006.22ms if (!ref($self)) {
26 $self = $self->new();
27 }
28
29500022.6ms500098.6ms my $parser_class = $self->_parser_class();
# spent 98.6ms making 5000 calls to XML::SAX::ParserFactory::_parser_class, avg 20µs/call
30
3150005.65ms my $version = '';
32500028.2ms50008.52ms if ($parser_class =~ s/\s*\(([\d\.]+)\)\s*$//) {
# spent 8.52ms making 5000 calls to XML::SAX::ParserFactory::CORE:subst, avg 2µs/call
33 $version = " $1";
34 }
35
36 {
37500310.4ms267µs
# spent 41µs (15+26) within XML::SAX::ParserFactory::BEGIN@37 which was called: # once (15µs+26µs) by XML::SAX::BEGIN@18 at line 37
no strict 'refs';
# spent 41µs making 1 call to XML::SAX::ParserFactory::BEGIN@37 # spent 26µs making 1 call to strict::unimport
38500017.2ms if (!keys %{"${parser_class}::"}) {
39151µs eval "use $parser_class $version;";
# spent 139µs executing statements in string eval
# includes 1.92ms spent executing 1 call to 1 sub defined therein.
40 }
41 }
42
43500043.0ms5000424ms return $parser_class->new(@parser_params);
# spent 424ms making 5000 calls to XML::SAX::ExpatXS::new, avg 85µs/call
44}
45
46
# spent 14µs within XML::SAX::ParserFactory::require_feature which was called: # once (14µs+0s) by main::BEGIN@3 at line 20 of MARC/File/XML.pm
sub require_feature {
4712µs my $self = shift;
4813µs my ($feature) = @_;
4913µs $self->{RequiredFeatures}{$feature}++;
5016µs return $self;
51}
52
53
# spent 98.6ms within XML::SAX::ParserFactory::_parser_class which was called 5000 times, avg 20µs/call: # 5000 times (98.6ms+0s) by XML::SAX::ParserFactory::parser at line 29, avg 20µs/call
sub _parser_class {
5450005.42ms my $self = shift;
55
56 # First try ParserPackage
5750005.08ms if ($XML::SAX::ParserPackage) {
58 return $XML::SAX::ParserPackage;
59 }
60
61 # Now check if required/preferred is there
6250007.47ms if ($self->{RequiredFeatures}) {
63500016.6ms my %required = %{$self->{RequiredFeatures}};
64 # note - we never go onto the next try (ParserDetails.ini),
65 # because if we can't provide the requested feature
66 # we need to throw an exception.
67 PARSER:
6850009.14ms foreach my $parser (reverse @{$self->{KnownParsers}}) {
69500016.1ms foreach my $feature (keys %required) {
70500017.6ms if (!exists $parser->{Features}{$feature}) {
71 next PARSER;
72 }
73 }
74 # got here - all features must exist!
75500030.4ms return $parser->{Name};
76 }
77 # TODO : should this be NotSupported() ?
78 throw XML::SAX::Exception (
79 Message => "Unable to provide required features",
80 );
81 }
82
83 # Next try SAX.ini
84 for my $dir (@INC) {
85 my $fh = gensym();
86 if (open($fh, "$dir/SAX.ini")) {
87 my $param_list = XML::SAX->_parse_ini_file($fh);
88 my $params = $param_list->[0]->{Features};
89 if ($params->{ParserPackage}) {
90 return $params->{ParserPackage};
91 }
92 else {
93 # we have required features (or nothing?)
94 PARSER:
95 foreach my $parser (reverse @{$self->{KnownParsers}}) {
96 foreach my $feature (keys %$params) {
97 if (!exists $parser->{Features}{$feature}) {
98 next PARSER;
99 }
100 }
101 return $parser->{Name};
102 }
103 XML::SAX->do_warn("Unable to provide SAX.ini required features. Using fallback\n");
104 }
105 last; # stop after first INI found
106 }
107 }
108
109 if (@{$self->{KnownParsers}}) {
110 return $self->{KnownParsers}[-1]{Name};
111 }
112 else {
113 return "XML::SAX::PurePerl"; # backup plan!
114 }
115}
116
11714µs1;
118__END__
 
# spent 8.52ms within XML::SAX::ParserFactory::CORE:subst which was called 5000 times, avg 2µs/call: # 5000 times (8.52ms+0s) by XML::SAX::ParserFactory::parser at line 32, avg 2µs/call
sub XML::SAX::ParserFactory::CORE:subst; # opcode