← Index
NYTProf Performance Profile   « line view »
For svc/members/upsert
  Run on Tue Jan 13 11:50:22 2015
Reported on Tue Jan 13 12:09:47 2015

Filename/usr/share/perl5/XML/SAX/ParserFactory.pm
StatementsExecuted 90 statements in 3.90ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
2112.57ms34.0msXML::SAX::ParserFactory::::parserXML::SAX::ParserFactory::parser
20112.52ms2.52msXML::SAX::ParserFactory::::CORE:openXML::SAX::ParserFactory::CORE:open (opcode)
1111.06ms1.18msXML::SAX::ParserFactory::::BEGIN@12XML::SAX::ParserFactory::BEGIN@12
211113µs2.70msXML::SAX::ParserFactory::::_parser_classXML::SAX::ParserFactory::_parser_class
21117µs4.44msXML::SAX::ParserFactory::::newXML::SAX::ParserFactory::new
11111µs22µsXML::SAX::ParserFactory::::BEGIN@5XML::SAX::ParserFactory::BEGIN@5
1119µs24µsXML::SAX::ParserFactory::::BEGIN@6XML::SAX::ParserFactory::BEGIN@6
1117µs25µsXML::SAX::ParserFactory::::BEGIN@10XML::SAX::ParserFactory::BEGIN@10
1116µs6µsXML::SAX::ParserFactory::::BEGIN@11XML::SAX::ParserFactory::BEGIN@11
2112µs2µsXML::SAX::ParserFactory::::CORE:substXML::SAX::ParserFactory::CORE:subst (opcode)
0000s0sXML::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$
2
3package XML::SAX::ParserFactory;
4
5224µs234µs
# spent 22µs (11+11) within XML::SAX::ParserFactory::BEGIN@5 which was called: # once (11µs+11µs) by XML::SAX::BEGIN@18 at line 5
use strict;
# spent 22µs making 1 call to XML::SAX::ParserFactory::BEGIN@5 # spent 11µs making 1 call to strict::import
6232µs240µs
# spent 24µs (9+16) within XML::SAX::ParserFactory::BEGIN@6 which was called: # once (9µs+16µs) by XML::SAX::BEGIN@18 at line 6
use vars qw($VERSION);
# spent 24µs making 1 call to XML::SAX::ParserFactory::BEGIN@6 # spent 16µs making 1 call to vars::import
7
81300ns$VERSION = '1.01';
9
10220µs244µs
# spent 25µs (7+19) within XML::SAX::ParserFactory::BEGIN@10 which was called: # once (7µs+19µs) by XML::SAX::BEGIN@18 at line 10
use Symbol qw(gensym);
# spent 25µs making 1 call to XML::SAX::ParserFactory::BEGIN@10 # spent 19µs making 1 call to Exporter::import
11220µs16µs
# spent 6µs within XML::SAX::ParserFactory::BEGIN@11 which was called: # once (6µs+0s) by XML::SAX::BEGIN@18 at line 11
use XML::SAX;
# spent 6µs making 1 call to XML::SAX::ParserFactory::BEGIN@11
1221.06ms11.18ms
# spent 1.18ms (1.06+117µs) within XML::SAX::ParserFactory::BEGIN@12 which was called: # once (1.06ms+117µs) by XML::SAX::BEGIN@18 at line 12
use XML::SAX::Exception;
# spent 1.18ms making 1 call to XML::SAX::ParserFactory::BEGIN@12
13
14
# spent 4.44ms (17µs+4.42) within XML::SAX::ParserFactory::new which was called 2 times, avg 2.22ms/call: # 2 times (17µs+4.42ms) by XML::SAX::ParserFactory::parser at line 25, avg 2.22ms/call
sub new {
152500ns my $class = shift;
1621µs my %params = @_; # TODO : Fix this in spec.
1722µs my $self = bless \%params, $class;
1828µs24.42ms $self->{KnownParsers} = XML::SAX->parsers();
# spent 4.42ms making 2 calls to XML::SAX::parsers, avg 2.21ms/call
1924µs return $self;
20}
21
22
# spent 34.0ms (2.57+31.5) within XML::SAX::ParserFactory::parser which was called 2 times, avg 17.0ms/call: # 2 times (2.57ms+31.5ms) by XML::Simple::build_tree at line 379 of XML/Simple.pm, avg 17.0ms/call
sub parser {
232600ns my $self = shift;
2422µs my @parser_params = @_;
2523µs24.44ms if (!ref($self)) {
# spent 4.44ms making 2 calls to XML::SAX::ParserFactory::new, avg 2.22ms/call
26 $self = $self->new();
27 }
28
2924µs22.70ms my $parser_class = $self->_parser_class();
# spent 2.70ms making 2 calls to XML::SAX::ParserFactory::_parser_class, avg 1.35ms/call
30
312700ns my $version = '';
3227µs22µs if ($parser_class =~ s/\s*\(([\d\.]+)\)\s*$//) {
# spent 2µs making 2 calls to XML::SAX::ParserFactory::CORE:subst, avg 1µs/call
33 $version = " $1";
34 }
35
36217µs27µs if (!$parser_class->can('new')) {
# spent 7µs making 2 calls to UNIVERSAL::can, avg 3µs/call
37136µs eval "require $parser_class $version;";
# spent 1.02ms executing statements in string eval
381400ns die $@ if $@;
39 }
40
41221µs292µs return $parser_class->new(@parser_params);
# spent 92µs making 2 calls to XML::SAX::Base::new, avg 46µs/call
42}
43
44sub require_feature {
45 my $self = shift;
46 my ($feature) = @_;
47 $self->{RequiredFeatures}{$feature}++;
48 return $self;
49}
50
51
# spent 2.70ms (113µs+2.59) within XML::SAX::ParserFactory::_parser_class which was called 2 times, avg 1.35ms/call: # 2 times (113µs+2.59ms) by XML::SAX::ParserFactory::parser at line 29, avg 1.35ms/call
sub _parser_class {
522700ns my $self = shift;
53
54 # First try ParserPackage
552600ns if ($XML::SAX::ParserPackage) {
56 return $XML::SAX::ParserPackage;
57 }
58
59 # Now check if required/preferred is there
602700ns if ($self->{RequiredFeatures}) {
61 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:
66 foreach my $parser (reverse @{$self->{KnownParsers}}) {
67 foreach my $feature (keys %required) {
68 if (!exists $parser->{Features}{$feature}) {
69 next PARSER;
70 }
71 }
72 # got here - all features must exist!
73 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
8222µs for my $dir (@INC) {
832019µs2066µs my $fh = gensym();
# spent 66µs making 20 calls to Symbol::gensym, avg 3µs/call
84202.60ms202.52ms if (open($fh, "$dir/SAX.ini")) {
# spent 2.52ms making 20 calls to XML::SAX::ParserFactory::CORE:open, avg 126µ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
107210µs if (@{$self->{KnownParsers}}) {
108 return $self->{KnownParsers}[-1]{Name};
109 }
110 else {
111 return "XML::SAX::PurePerl"; # backup plan!
112 }
113}
114
11512µs1;
116__END__
 
# spent 2.52ms within XML::SAX::ParserFactory::CORE:open which was called 20 times, avg 126µs/call: # 20 times (2.52ms+0s) by XML::SAX::ParserFactory::_parser_class at line 84, avg 126µs/call
sub XML::SAX::ParserFactory::CORE:open; # opcode
# spent 2µs within XML::SAX::ParserFactory::CORE:subst which was called 2 times, avg 1µs/call: # 2 times (2µs+0s) by XML::SAX::ParserFactory::parser at line 32, avg 1µs/call
sub XML::SAX::ParserFactory::CORE:subst; # opcode