← 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.pm
StatementsExecuted 125 statements in 9.53ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
1113.78ms8.60msXML::SAX::::BEGIN@18XML::SAX::BEGIN@18
111835µs1.34msXML::SAX::::_parse_ini_fileXML::SAX::_parse_ini_file
3031274µs274µsXML::SAX::::CORE:substXML::SAX::CORE:subst (opcode)
111238µs2.33msXML::SAX::::load_parsersXML::SAX::load_parsers
1921150µs150µsXML::SAX::::CORE:matchXML::SAX::CORE:match (opcode)
11189µs89µsXML::SAX::::CORE:openXML::SAX::CORE:open (opcode)
111184µs84µsXML::SAX::::CORE:readlineXML::SAX::CORE:readline (opcode)
11181µs178µsXML::SAX::::BEGIN@5XML::SAX::BEGIN@5
21156µs2.39msXML::SAX::::parsersXML::SAX::parsers
11155µs230µsXML::SAX::::BEGIN@15XML::SAX::BEGIN@15
11155µs294µsXML::SAX::::BEGIN@20XML::SAX::BEGIN@20
11152µs305µsXML::SAX::::BEGIN@17XML::SAX::BEGIN@17
11150µs349µsXML::SAX::::BEGIN@6XML::SAX::BEGIN@6
11148µs227µsXML::SAX::::BEGIN@22XML::SAX::BEGIN@22
11144µs214µsXML::SAX::::BEGIN@23XML::SAX::BEGIN@23
11131µs31µsXML::SAX::::BEGIN@10XML::SAX::BEGIN@10
11123µs23µsXML::SAX::::BEGIN@16XML::SAX::BEGIN@16
0000s0sXML::SAX::::add_parserXML::SAX::add_parser
0000s0sXML::SAX::::do_warnXML::SAX::do_warn
0000s0sXML::SAX::::remove_parserXML::SAX::remove_parser
0000s0sXML::SAX::::save_parsersXML::SAX::save_parsers
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;
4
52175µs2275µs
# spent 178µs (81+97) within XML::SAX::BEGIN@5 which was called: # once (81µs+97µs) by XML::Simple::build_tree at line 5
use strict;
# spent 178µs making 1 call to XML::SAX::BEGIN@5 # spent 97µs making 1 call to strict::import
62623µs2648µs
# spent 349µs (50+299) within XML::SAX::BEGIN@6 which was called: # once (50µs+299µs) by XML::Simple::build_tree at line 6
use vars qw($VERSION @ISA @EXPORT_OK);
# spent 349µs making 1 call to XML::SAX::BEGIN@6 # spent 299µs making 1 call to vars::import
7
816µs$VERSION = '0.99';
9
102230µs131µs
# spent 31µs within XML::SAX::BEGIN@10 which was called: # once (31µs+0s) by XML::Simple::build_tree at line 10
use Exporter ();
# spent 31µs making 1 call to XML::SAX::BEGIN@10
11157µs@ISA = ('Exporter');
12
1317µs@EXPORT_OK = qw(Namespaces Validation);
14
152150µs2405µs
# spent 230µs (55+175) within XML::SAX::BEGIN@15 which was called: # once (55µs+175µs) by XML::Simple::build_tree at line 15
use File::Basename qw(dirname);
# spent 230µs making 1 call to XML::SAX::BEGIN@15 # spent 175µs making 1 call to Exporter::import
162134µs123µs
# spent 23µs within XML::SAX::BEGIN@16 which was called: # once (23µs+0s) by XML::Simple::build_tree at line 16
use File::Spec ();
# spent 23µs making 1 call to XML::SAX::BEGIN@16
172142µs2558µs
# spent 305µs (52+253) within XML::SAX::BEGIN@17 which was called: # once (52µs+253µs) by XML::Simple::build_tree at line 17
use Symbol qw(gensym);
# spent 305µs making 1 call to XML::SAX::BEGIN@17 # spent 253µs making 1 call to Exporter::import
182696µs18.60ms
# spent 8.60ms (3.78+4.83) within XML::SAX::BEGIN@18 which was called: # once (3.78ms+4.83ms) by XML::Simple::build_tree at line 18
use XML::SAX::ParserFactory (); # loaded for simplicity
# spent 8.60ms making 1 call to XML::SAX::BEGIN@18
19
202178µs2533µs
# spent 294µs (55+239) within XML::SAX::BEGIN@20 which was called: # once (55µs+239µs) by XML::Simple::build_tree at line 20
use constant PARSER_DETAILS => "ParserDetails.ini";
# spent 294µs making 1 call to XML::SAX::BEGIN@20 # spent 239µs making 1 call to constant::import
21
222160µs2405µs
# spent 227µs (48+179) within XML::SAX::BEGIN@22 which was called: # once (48µs+179µs) by XML::Simple::build_tree at line 22
use constant Namespaces => "http://xml.org/sax/features/namespaces";
# spent 227µs making 1 call to XML::SAX::BEGIN@22 # spent 179µs making 1 call to constant::import
2325.23ms2384µs
# spent 214µs (44+170) within XML::SAX::BEGIN@23 which was called: # once (44µs+170µs) by XML::Simple::build_tree at line 23
use constant Validation => "http://xml.org/sax/features/validation";
# spent 214µs making 1 call to XML::SAX::BEGIN@23 # spent 170µs making 1 call to constant::import
24
2512µsmy $known_parsers = undef;
26
27# load_parsers takes the ParserDetails.ini file out of the same directory
28# that XML::SAX is in, and looks at it. Format in POD below
29
30=begin EXAMPLE
31
32[XML::SAX::PurePerl]
33http://xml.org/sax/features/namespaces = 1
34http://xml.org/sax/features/validation = 0
35# a comment
36
37# blank lines ignored
38
39[XML::SAX::AnotherParser]
40http://xml.org/sax/features/namespaces = 0
41http://xml.org/sax/features/validation = 1
42
43=end EXAMPLE
44
45=cut
46
47
# spent 2.33ms (238µs+2.10) within XML::SAX::load_parsers which was called: # once (238µs+2.10ms) by XML::SAX::parsers at line 114
sub load_parsers {
4813µs my $class = shift;
4911µs my $dir = shift;
50
51 # reset parsers
5214µs $known_parsers = [];
53
54 # get directory from wherever XML::SAX is installed
5515µs if (!$dir) {
5615µs $dir = $INC{'XML/SAX.pm'};
57113µs1312µs $dir = dirname($dir);
# spent 312µs making 1 call to File::Basename::dirname
58 }
59
60113µs148µs my $fh = gensym();
# spent 48µs making 1 call to Symbol::gensym
611146µs2394µs if (!open($fh, File::Spec->catfile($dir, "SAX", PARSER_DETAILS))) {
# spent 305µs making 1 call to File::Spec::Unix::catfile # spent 89µs making 1 call to XML::SAX::CORE:open
62 XML::SAX->do_warn("could not find " . PARSER_DETAILS . " in $dir/SAX\n");
63 return $class;
64 }
65
66122µs11.34ms $known_parsers = $class->_parse_ini_file($fh);
# spent 1.34ms making 1 call to XML::SAX::_parse_ini_file
67
68185µs return $class;
69}
70
71
# spent 1.34ms (835µs+508µs) within XML::SAX::_parse_ini_file which was called: # once (835µs+508µs) by XML::SAX::load_parsers at line 66
sub _parse_ini_file {
7214µs my $class = shift;
7313µs my ($fh) = @_;
74
7511µs my @config;
76
7711µs my $lineno = 0;
781239µs1184µs while (defined(my $line = <$fh>)) {
# spent 84µs making 11 calls to XML::SAX::CORE:readline, avg 8µs/call
79107µs $lineno++;
801017µs my $original = $line;
81 # strip whitespace
8210312µs10197µs $line =~ s/\s*$//m;
# spent 197µs making 10 calls to XML::SAX::CORE:subst, avg 20µs/call
8310150µs1051µs $line =~ s/^\s*//m;
# spent 51µs making 10 calls to XML::SAX::CORE:subst, avg 5µs/call
84 # strip comments
8510117µs1026µs $line =~ s/[#;].*$//m;
# spent 26µs making 10 calls to XML::SAX::CORE:subst, avg 3µs/call
86 # ignore blanks
8710160µs1042µs next if $line =~ /^$/m;
# spent 42µs making 10 calls to XML::SAX::CORE:match, avg 4µs/call
88
89 # heading
906207µs9108µs if ($line =~ /^\[\s*(.*)\s*\]$/m) {
# spent 108µs making 9 calls to XML::SAX::CORE:match, avg 12µs/call
91343µs push @config, { Name => $1 };
92312µs next;
93 }
94
95 # instruction
96 elsif ($line =~ /^(.*?)\s*?=\s*(.*)$/) {
9737µs unless(@config) {
98 push @config, { Name => '' };
99 }
100348µs $config[-1]{Features}{$1} = $2;
101 }
102
103 # not whitespace, comment, or instruction
104 else {
105 die "Invalid line in ini: $lineno\n>>> $original\n";
106 }
107 }
108
109125µs return \@config;
110}
111
112
# spent 2.39ms (56µs+2.33) within XML::SAX::parsers which was called 2 times, avg 1.19ms/call: # 2 times (56µs+2.33ms) by XML::SAX::ParserFactory::new at line 18 of XML/SAX/ParserFactory.pm, avg 1.19ms/call
sub parsers {
11326µs my $class = shift;
114215µs12.33ms if (!$known_parsers) {
# spent 2.33ms making 1 call to XML::SAX::load_parsers
115 $class->load_parsers();
116 }
117237µs return $known_parsers;
118}
119
120sub remove_parser {
121 my $class = shift;
122 my ($parser_module) = @_;
123
124 if (!$known_parsers) {
125 $class->load_parsers();
126 }
127
128 @$known_parsers = grep { $_->{Name} ne $parser_module } @$known_parsers;
129
130 return $class;
131}
132
133sub add_parser {
134 my $class = shift;
135 my ($parser_module) = @_;
136
137 if (!$known_parsers) {
138 $class->load_parsers();
139 }
140
141 # first load module, then query features, then push onto known_parsers,
142
143 my $parser_file = $parser_module;
144 $parser_file =~ s/::/\//g;
145 $parser_file .= ".pm";
146
147 require $parser_file;
148
149 my @features = $parser_module->supported_features();
150
151 my $new = { Name => $parser_module };
152 foreach my $feature (@features) {
153 $new->{Features}{$feature} = 1;
154 }
155
156 # If exists in list already, move to end.
157 my $done = 0;
158 my $pos = undef;
159 for (my $i = 0; $i < @$known_parsers; $i++) {
160 my $p = $known_parsers->[$i];
161 if ($p->{Name} eq $parser_module) {
162 $pos = $i;
163 }
164 }
165 if (defined $pos) {
166 splice(@$known_parsers, $pos, 1);
167 push @$known_parsers, $new;
168 $done++;
169 }
170
171 # Otherwise (not in list), add at end of list.
172 if (!$done) {
173 push @$known_parsers, $new;
174 }
175
176 return $class;
177}
178
179sub save_parsers {
180 my $class = shift;
181
182 # get directory from wherever XML::SAX is installed
183 my $dir = $INC{'XML/SAX.pm'};
184 $dir = dirname($dir);
185
186 my $file = File::Spec->catfile($dir, "SAX", PARSER_DETAILS);
187 chmod 0644, $file;
188 unlink($file);
189
190 my $fh = gensym();
191 open($fh, ">$file") ||
192 die "Cannot write to $file: $!";
193
194 foreach my $p (@$known_parsers) {
195 print $fh "[$p->{Name}]\n";
196 foreach my $key (keys %{$p->{Features}}) {
197 print $fh "$key = $p->{Features}{$key}\n";
198 }
199 print $fh "\n";
200 }
201
202 print $fh "\n";
203
204 close $fh;
205
206 return $class;
207}
208
209sub do_warn {
210 my $class = shift;
211 # Don't output warnings if running under Test::Harness
212 warn(@_) unless $ENV{HARNESS_ACTIVE};
213}
214
215123µs1;
216__END__
 
# spent 150µs within XML::SAX::CORE:match which was called 19 times, avg 8µs/call: # 10 times (42µs+0s) by XML::SAX::_parse_ini_file at line 87, avg 4µs/call # 9 times (108µs+0s) by XML::SAX::_parse_ini_file at line 90, avg 12µs/call
sub XML::SAX::CORE:match; # opcode
# spent 89µs within XML::SAX::CORE:open which was called: # once (89µs+0s) by XML::SAX::load_parsers at line 61
sub XML::SAX::CORE:open; # opcode
# spent 84µs within XML::SAX::CORE:readline which was called 11 times, avg 8µs/call: # 11 times (84µs+0s) by XML::SAX::_parse_ini_file at line 78, avg 8µs/call
sub XML::SAX::CORE:readline; # opcode
# spent 274µs within XML::SAX::CORE:subst which was called 30 times, avg 9µs/call: # 10 times (197µs+0s) by XML::SAX::_parse_ini_file at line 82, avg 20µs/call # 10 times (51µs+0s) by XML::SAX::_parse_ini_file at line 83, avg 5µs/call # 10 times (26µs+0s) by XML::SAX::_parse_ini_file at line 85, avg 3µs/call
sub XML::SAX::CORE:subst; # opcode