← Index
NYTProf Performance Profile   « line view »
For webmerge/scripts/webmerge.pl
  Run on Mon Oct 7 02:42:42 2013
Reported on Mon Oct 7 03:03:27 2013

Filename/usr/lib64/perl5/vendor_perl/5.16.0/XML/SAX/ParserFactory.pm
StatementsExecuted 86 statements in 5.96ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
2114.87ms313msXML::SAX::ParserFactory::::parserXML::SAX::ParserFactory::parser
1113.17ms4.16msXML::SAX::ParserFactory::::BEGIN@12XML::SAX::ParserFactory::BEGIN@12
211808µs1.97msXML::SAX::ParserFactory::::_parser_classXML::SAX::ParserFactory::_parser_class
1811600µs600µsXML::SAX::ParserFactory::::CORE:openXML::SAX::ParserFactory::CORE:open (opcode)
211149µs2.54msXML::SAX::ParserFactory::::newXML::SAX::ParserFactory::new
11184µs183µsXML::SAX::ParserFactory::::BEGIN@5XML::SAX::ParserFactory::BEGIN@5
11179µs240µsXML::SAX::ParserFactory::::BEGIN@10XML::SAX::ParserFactory::BEGIN@10
11157µs57µsXML::SAX::ParserFactory::::BEGIN@11XML::SAX::ParserFactory::BEGIN@11
11151µs190µsXML::SAX::ParserFactory::::BEGIN@6XML::SAX::ParserFactory::BEGIN@6
21110µs10µ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
52162µs2282µs
# spent 183µs (84+99) within XML::SAX::ParserFactory::BEGIN@5 which was called: # once (84µs+99µs) by XML::SAX::BEGIN@18 at line 5
use strict;
# spent 183µs making 1 call to XML::SAX::ParserFactory::BEGIN@5 # spent 99µs making 1 call to strict::import
62198µs2330µs
# spent 190µs (51+140) within XML::SAX::ParserFactory::BEGIN@6 which was called: # once (51µs+140µs) by XML::SAX::BEGIN@18 at line 6
use vars qw($VERSION);
# spent 190µs making 1 call to XML::SAX::ParserFactory::BEGIN@6 # spent 140µs making 1 call to vars::import
7
814µs$VERSION = '1.01';
9
102165µs2400µs
# spent 240µs (79+160) within XML::SAX::ParserFactory::BEGIN@10 which was called: # once (79µs+160µs) by XML::SAX::BEGIN@18 at line 10
use Symbol qw(gensym);
# spent 240µs making 1 call to XML::SAX::ParserFactory::BEGIN@10 # spent 160µs making 1 call to Exporter::import
112163µs157µs
# spent 57µs within XML::SAX::ParserFactory::BEGIN@11 which was called: # once (57µs+0s) by XML::SAX::BEGIN@18 at line 11
use XML::SAX;
# spent 57µs making 1 call to XML::SAX::ParserFactory::BEGIN@11
1223.29ms14.16ms
# spent 4.16ms (3.17+987µs) within XML::SAX::ParserFactory::BEGIN@12 which was called: # once (3.17ms+987µs) by XML::SAX::BEGIN@18 at line 12
use XML::SAX::Exception;
# spent 4.16ms making 1 call to XML::SAX::ParserFactory::BEGIN@12
13
14
# spent 2.54ms (149µs+2.39) within XML::SAX::ParserFactory::new which was called 2 times, avg 1.27ms/call: # 2 times (149µs+2.39ms) by XML::SAX::ParserFactory::parser at line 25, avg 1.27ms/call
sub new {
1526µs my $class = shift;
1629µs my %params = @_; # TODO : Fix this in spec.
17252µs my $self = bless \%params, $class;
18242µs22.39ms $self->{KnownParsers} = XML::SAX->parsers();
# spent 2.39ms making 2 calls to XML::SAX::parsers, avg 1.19ms/call
19240µs return $self;
20}
21
22
# spent 313ms (4.87+308) within XML::SAX::ParserFactory::parser which was called 2 times, avg 157ms/call: # 2 times (4.87ms+308ms) by XML::Simple::build_tree at line 379 of XML/Simple.pm, avg 157ms/call
sub parser {
2328µs my $self = shift;
24215µs my @parser_params = @_;
25240µs22.54ms if (!ref($self)) {
# spent 2.54ms making 2 calls to XML::SAX::ParserFactory::new, avg 1.27ms/call
26 $self = $self->new();
27 }
28
29230µs21.97ms my $parser_class = $self->_parser_class();
# spent 1.97ms making 2 calls to XML::SAX::ParserFactory::_parser_class, avg 986µs/call
30
3125µs my $version = '';
32248µs210µs if ($parser_class =~ s/\s*\(([\d\.]+)\)\s*$//) {
# spent 10µs making 2 calls to XML::SAX::ParserFactory::CORE:subst, avg 5µs/call
33 $version = " $1";
34 }
35
36277µs222µs if (!$parser_class->can('new')) {
# spent 22µs making 2 calls to UNIVERSAL::can, avg 11µs/call
371133µs eval "require $parser_class $version;";
# spent 423µs executing statements in string eval
3812µs die $@ if $@;
39 }
40
412129µs2693µs return $parser_class->new(@parser_params);
# spent 693µs making 2 calls to XML::SAX::Base::new, avg 346µ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 1.97ms (808µs+1.16) within XML::SAX::ParserFactory::_parser_class which was called 2 times, avg 986µs/call: # 2 times (808µs+1.16ms) by XML::SAX::ParserFactory::parser at line 29, avg 986µs/call
sub _parser_class {
5227µs my $self = shift;
53
54 # First try ParserPackage
5522µs if ($XML::SAX::ParserPackage) {
56 return $XML::SAX::ParserPackage;
57 }
58
59 # Now check if required/preferred is there
6024µs 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
82213µs for my $dir (@INC) {
8318181µs18563µs my $fh = gensym();
# spent 563µs making 18 calls to Symbol::gensym, avg 31µs/call
84181.07ms18600µs if (open($fh, "$dir/SAX.ini")) {
# spent 600µs making 18 calls to XML::SAX::ParserFactory::CORE:open, avg 33µ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
107256µs if (@{$self->{KnownParsers}}) {
108 return $self->{KnownParsers}[-1]{Name};
109 }
110 else {
111 return "XML::SAX::PurePerl"; # backup plan!
112 }
113}
114
115112µs1;
116__END__
 
# spent 600µs within XML::SAX::ParserFactory::CORE:open which was called 18 times, avg 33µs/call: # 18 times (600µs+0s) by XML::SAX::ParserFactory::_parser_class at line 84, avg 33µs/call
sub XML::SAX::ParserFactory::CORE:open; # opcode
# spent 10µs within XML::SAX::ParserFactory::CORE:subst which was called 2 times, avg 5µs/call: # 2 times (10µs+0s) by XML::SAX::ParserFactory::parser at line 32, avg 5µs/call
sub XML::SAX::ParserFactory::CORE:subst; # opcode