← Index
NYTProf Performance Profile   « block view • line view • sub view »
For conv.pl
  Run on Sun Nov 14 21:14:18 2010
Reported on Sun Nov 14 21:17:54 2010

Filename/usr/share/perl5/XML/SAX/ParserFactory.pm
StatementsExecuted 85030 statements in 296ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
500011172ms797msXML::SAX::ParserFactory::::parserXML::SAX::ParserFactory::parser
500011113ms113msXML::SAX::ParserFactory::::_parser_classXML::SAX::ParserFactory::_parser_class
5000119.82ms9.82msXML::SAX::ParserFactory::::CORE:substXML::SAX::ParserFactory::CORE:subst (opcode)
1111.08ms3.24msXML::SAX::ParserFactory::::BEGIN@12XML::SAX::ParserFactory::BEGIN@12
11129µs1.27msXML::SAX::ParserFactory::::newXML::SAX::ParserFactory::new
11124µs31µsXML::SAX::ParserFactory::::BEGIN@5XML::SAX::ParserFactory::BEGIN@5
11117µs17µsXML::SAX::ParserFactory::::require_featureXML::SAX::ParserFactory::require_feature
11117µs60µsXML::SAX::ParserFactory::::BEGIN@6XML::SAX::ParserFactory::BEGIN@6
11116µs71µsXML::SAX::ParserFactory::::BEGIN@10XML::SAX::ParserFactory::BEGIN@10
11115µs43µsXML::SAX::ParserFactory::::BEGIN@37XML::SAX::ParserFactory::BEGIN@37
11113µs13µsXML::SAX::ParserFactory::::BEGIN@11XML::SAX::ParserFactory::BEGIN@11
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
5399µ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µs2103µs
# spent 60µs (17+43) within XML::SAX::ParserFactory::BEGIN@6 which was called: # once (17µs+43µs) by XML::SAX::BEGIN@18 at line 6
use vars qw($VERSION);
# spent 60µs making 1 call to XML::SAX::ParserFactory::BEGIN@6 # spent 43µs making 1 call to vars::import
7
812µs$VERSION = '1.01';
9
10339µs2126µs
# spent 71µs (16+55) within XML::SAX::ParserFactory::BEGIN@10 which was called: # once (16µs+55µs) by XML::SAX::BEGIN@18 at line 10
use Symbol qw(gensym);
# spent 71µs making 1 call to XML::SAX::ParserFactory::BEGIN@10 # spent 55µs making 1 call to Exporter::import
11341µs113µs
# spent 13µs within XML::SAX::ParserFactory::BEGIN@11 which was called: # once (13µs+0s) by XML::SAX::BEGIN@18 at line 11
use XML::SAX;
# spent 13µs making 1 call to XML::SAX::ParserFactory::BEGIN@11
123367µs13.24ms
# spent 3.24ms (1.08+2.16) within XML::SAX::ParserFactory::BEGIN@12 which was called: # once (1.08ms+2.16ms) by XML::SAX::BEGIN@18 at line 12
use XML::SAX::Exception;
# spent 3.24ms making 1 call to XML::SAX::ParserFactory::BEGIN@12
13
14
# spent 1.27ms (29µs+1.24) within XML::SAX::ParserFactory::new which was called: # once (29µs+1.24ms) 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.24ms $self->{KnownParsers} = XML::SAX->parsers();
# spent 1.24ms making 1 call to XML::SAX::parsers
1916µs return $self;
20}
21
22
# spent 797ms (172+624) within XML::SAX::ParserFactory::parser which was called 5000 times, avg 159µs/call: # 5000 times (172ms+624ms) by MARC::File::XML::decode at line 439 of MARC/File/XML.pm, avg 159µs/call
sub parser {
2350007.39ms my $self = shift;
24500015.7ms my @parser_params = @_;
2550006.72ms if (!ref($self)) {
26 $self = $self->new();
27 }
28
29500026.5ms5000113ms my $parser_class = $self->_parser_class();
# spent 113ms making 5000 calls to XML::SAX::ParserFactory::_parser_class, avg 23µs/call
30
3150006.67ms my $version = '';
32500031.2ms50009.82ms if ($parser_class =~ s/\s*\(([\d\.]+)\)\s*$//) {
# spent 9.82ms making 5000 calls to XML::SAX::ParserFactory::CORE:subst, avg 2µs/call
33 $version = " $1";
34 }
35
36 {
37500310.9ms271µs
# spent 43µs (15+28) within XML::SAX::ParserFactory::BEGIN@37 which was called: # once (15µs+28µs) by XML::SAX::BEGIN@18 at line 37
no strict 'refs';
# spent 43µs making 1 call to XML::SAX::ParserFactory::BEGIN@37 # spent 28µs making 1 call to strict::unimport
38500019.0ms if (!keys %{"${parser_class}::"}) {
39152µs eval "use $parser_class $version;";
# spent 157µs executing statements in string eval
# includes 2.74ms spent executing 1 call to 1 sub defined therein.
40 }
41 }
42
43500048.4ms5000486ms return $parser_class->new(@parser_params);
# spent 486ms making 5000 calls to XML::SAX::Base::new, avg 97µs/call
44}
45
46
# spent 17µs within XML::SAX::ParserFactory::require_feature which was called: # once (17µs+0s) by main::BEGIN@3 at line 20 of MARC/File/XML.pm
sub require_feature {
4711µs my $self = shift;
4818µs my ($feature) = @_;
4914µs $self->{RequiredFeatures}{$feature}++;
5016µs return $self;
51}
52
53
# spent 113ms within XML::SAX::ParserFactory::_parser_class which was called 5000 times, avg 23µs/call: # 5000 times (113ms+0s) by XML::SAX::ParserFactory::parser at line 29, avg 23µs/call
sub _parser_class {
5450006.58ms my $self = shift;
55
56 # First try ParserPackage
5750005.81ms if ($XML::SAX::ParserPackage) {
58 return $XML::SAX::ParserPackage;
59 }
60
61 # Now check if required/preferred is there
6250009.84ms if ($self->{RequiredFeatures}) {
63500017.1ms 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:
68500011.8ms foreach my $parser (reverse @{$self->{KnownParsers}}) {
69500017.3ms foreach my $feature (keys %required) {
70500020.3ms if (!exists $parser->{Features}{$feature}) {
71 next PARSER;
72 }
73 }
74 # got here - all features must exist!
75500033.6ms 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
11715µs1;
118__END__
 
# spent 9.82ms within XML::SAX::ParserFactory::CORE:subst which was called 5000 times, avg 2µs/call: # 5000 times (9.82ms+0s) by XML::SAX::ParserFactory::parser at line 32, avg 2µs/call
sub XML::SAX::ParserFactory::CORE:subst; # opcode