← 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:13 2010

Filename/usr/lib/perl5/XML/SAX/ExpatXS.pm
StatementsExecuted 270030 statements in 7.88s
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
5000117.34s26.7sXML::SAX::ExpatXS::::ParseStringXML::SAX::ExpatXS::ParseString (xsub)
500011612ms28.8sXML::SAX::ExpatXS::::_parseXML::SAX::ExpatXS::_parse
500011287ms424msXML::SAX::ExpatXS::::newXML::SAX::ExpatXS::new
50001176.6ms28.9sXML::SAX::ExpatXS::::_parse_stringXML::SAX::ExpatXS::_parse_string
50001163.8ms63.8msXML::SAX::ExpatXS::::ParserCreateXML::SAX::ExpatXS::ParserCreate (xsub)
50001141.3ms41.3msXML::SAX::ExpatXS::::ParserFreeXML::SAX::ExpatXS::ParserFree (xsub)
50001133.9ms33.9msXML::SAX::ExpatXS::::set_featureXML::SAX::ExpatXS::set_feature
50001131.3ms31.3msXML::SAX::ExpatXS::::GetLocatorXML::SAX::ExpatXS::GetLocator (xsub)
50001113.9ms13.9msXML::SAX::ExpatXS::::ExpatVersionXML::SAX::ExpatXS::ExpatVersion (xsub)
50001112.7ms12.7msXML::SAX::ExpatXS::::SetCallbacksXML::SAX::ExpatXS::SetCallbacks (xsub)
50001112.3ms12.3msXML::SAX::ExpatXS::::GetRecognizedStringXML::SAX::ExpatXS::GetRecognizedString (xsub)
50001111.2ms11.2msXML::SAX::ExpatXS::::GetExternEntXML::SAX::ExpatXS::GetExternEnt (xsub)
1113.01ms3.10msXML::SAX::ExpatXS::::BEGIN@6XML::SAX::ExpatXS::BEGIN@6
1111.59ms2.58msXML::SAX::ExpatXS::::BEGIN@5XML::SAX::ExpatXS::BEGIN@5
111100µs100µsXML::SAX::ExpatXS::::bootstrapXML::SAX::ExpatXS::bootstrap (xsub)
11126µs32µsXML::SAX::ExpatXS::::BEGIN@2XML::SAX::ExpatXS::BEGIN@2
11119µs378µsXML::SAX::ExpatXS::::BEGIN@10XML::SAX::ExpatXS::BEGIN@10
11117µs93µsXML::SAX::ExpatXS::::BEGIN@9XML::SAX::ExpatXS::BEGIN@9
11116µs16µsXML::SAX::ExpatXS::::BEGIN@7XML::SAX::ExpatXS::BEGIN@7
11115µs90µsXML::SAX::ExpatXS::::BEGIN@3XML::SAX::ExpatXS::BEGIN@3
1118µs8µsXML::SAX::ExpatXS::::BEGIN@8XML::SAX::ExpatXS::BEGIN@8
0000s0sXML::SAX::ExpatXS::::_get_external_entityXML::SAX::ExpatXS::_get_external_entity
0000s0sXML::SAX::ExpatXS::::_get_handler_methodsXML::SAX::ExpatXS::_get_handler_methods
0000s0sXML::SAX::ExpatXS::::_parse_bytestreamXML::SAX::ExpatXS::_parse_bytestream
0000s0sXML::SAX::ExpatXS::::_parse_characterstreamXML::SAX::ExpatXS::_parse_characterstream
0000s0sXML::SAX::ExpatXS::::_parse_systemidXML::SAX::ExpatXS::_parse_systemid
0000s0sXML::SAX::ExpatXS::::get_featureXML::SAX::ExpatXS::get_feature
0000s0sXML::SAX::ExpatXS::::get_featuresXML::SAX::ExpatXS::get_features
0000s0sXML::SAX::ExpatXS::::supported_featuresXML::SAX::ExpatXS::supported_features
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package XML::SAX::ExpatXS;
2359µs238µs
# spent 32µs (26+6) within XML::SAX::ExpatXS::BEGIN@2 which was called: # once (26µs+6µs) by XML::SAX::ParserFactory::BEGIN@1 at line 2
use strict;
# spent 32µs making 1 call to XML::SAX::ExpatXS::BEGIN@2 # spent 6µs making 1 call to strict::import
3350µs2165µs
# spent 90µs (15+75) within XML::SAX::ExpatXS::BEGIN@3 which was called: # once (15µs+75µs) by XML::SAX::ParserFactory::BEGIN@1 at line 3
use vars qw($VERSION @ISA);
# spent 90µs making 1 call to XML::SAX::ExpatXS::BEGIN@3 # spent 75µs making 1 call to vars::import
4
53166µs12.58ms
# spent 2.58ms (1.59+983µs) within XML::SAX::ExpatXS::BEGIN@5 which was called: # once (1.59ms+983µs) by XML::SAX::ParserFactory::BEGIN@1 at line 5
use XML::SAX::ExpatXS::Encoding;
# spent 2.58ms making 1 call to XML::SAX::ExpatXS::BEGIN@5
63170µs13.10ms
# spent 3.10ms (3.01+93µs) within XML::SAX::ExpatXS::BEGIN@6 which was called: # once (3.01ms+93µs) by XML::SAX::ParserFactory::BEGIN@1 at line 6
use XML::SAX::ExpatXS::Preload;
# spent 3.10ms making 1 call to XML::SAX::ExpatXS::BEGIN@6
7342µs116µs
# spent 16µs within XML::SAX::ExpatXS::BEGIN@7 which was called: # once (16µs+0s) by XML::SAX::ParserFactory::BEGIN@1 at line 7
use XML::SAX::Base;
# spent 16µs making 1 call to XML::SAX::ExpatXS::BEGIN@7
8336µs18µs
# spent 8µs within XML::SAX::ExpatXS::BEGIN@8 which was called: # once (8µs+0s) by XML::SAX::ParserFactory::BEGIN@1 at line 8
use DynaLoader ();
# spent 8µs making 1 call to XML::SAX::ExpatXS::BEGIN@8
9342µs2169µs
# spent 93µs (17+76) within XML::SAX::ExpatXS::BEGIN@9 which was called: # once (17µs+76µs) by XML::SAX::ParserFactory::BEGIN@1 at line 9
use Carp;
# spent 93µs making 1 call to XML::SAX::ExpatXS::BEGIN@9 # spent 76µs making 1 call to Exporter::import
1031.50ms2737µs
# spent 378µs (19+359) within XML::SAX::ExpatXS::BEGIN@10 which was called: # once (19µs+359µs) by XML::SAX::ParserFactory::BEGIN@1 at line 10
use IO::File;
# spent 378µs making 1 call to XML::SAX::ExpatXS::BEGIN@10 # spent 359µs making 1 call to Exporter::import
11
1211µs$VERSION = '1.31';
13124µs@ISA = qw(DynaLoader XML::SAX::Base XML::SAX::ExpatXS::Preload);
14
15110µs1550µsXML::SAX::ExpatXS->bootstrap($VERSION);
# spent 550µs making 1 call to DynaLoader::bootstrap
16
17121µsmy @features = (
18 ['http://xml.org/sax/features/namespaces', 1],
19 ['http://xml.org/sax/features/external-general-entities', 1],
20 ['http://xml.org/sax/features/external-parameter-entities', 0],
21 ['http://xml.org/sax/features/xmlns-uris', 0],
22 ['http://xmlns.perl.org/sax/xmlns-uris', 1],
23 ['http://xmlns.perl.org/sax/version-2.1', 1],
24 ['http://xmlns.perl.org/sax/join-character-data', 1],
25 ['http://xmlns.perl.org/sax/ns-attributes', 1],
26 ['http://xmlns.perl.org/sax/locator', 1],
27 ['http://xmlns.perl.org/sax/recstring', 0]
28 );
29115µsmy @supported_features = map($_->[0], @features);
30
31
32#------------------------------------------------------------
33# API methods
34#------------------------------------------------------------
35
36
# spent 424ms (287+137) within XML::SAX::ExpatXS::new which was called 5000 times, avg 85µs/call: # 5000 times (287ms+137ms) by XML::SAX::ParserFactory::parser at line 43 of XML/SAX/ParserFactory.pm, avg 85µs/call
sub new {
3750007.72ms my $proto = shift;
38500023.5ms my $options = ($#_ == 0) ? shift : { @_ };
39
40500013.4ms foreach (@features) {
4150000156ms $options->{Features}->{$_->[0]} = $_->[1];
42 }
43
44500042.0ms500013.9ms $options->{ExpatVersion} = ExpatVersion();
# spent 13.9ms making 5000 calls to XML::SAX::ExpatXS::ExpatVersion, avg 3µs/call
45
46500057.6ms5000123ms return $proto->SUPER::new($options);
# spent 123ms making 5000 calls to XML::SAX::Base::new, avg 25µs/call
47}
48
49sub get_feature {
50 my ($self, $feat) = @_;
51 if (exists $self->{Features}->{$feat}) {
52 return $self->{Features}->{$feat};
53 }
54 else {
55 return $self->SUPER::get_feature($feat);
56 }
57 }
58
59
# spent 33.9ms within XML::SAX::ExpatXS::set_feature which was called 5000 times, avg 7µs/call: # 5000 times (33.9ms+0s) by XML::SAX::Base::new at line 2585 of XML/SAX/Base.pm, avg 7µs/call
sub set_feature {
6050008.77ms my ($self, $feat, $val) = @_;
61500032.5ms if (exists $self->{Features}->{$feat}) {
62 return $self->{Features}->{$feat} = $val;
63 }
64 else {
65 return $self->SUPER::set_feature($feat, $val);
66 }
67 }
68
69sub get_features {
70 my $self = shift;
71 return %{$self->{Features}};
72}
73
74sub supported_features {
75 my $self = shift;
76
77 return @supported_features;
78}
79
80#------------------------------------------------------------
81# internal methods
82#------------------------------------------------------------
83
84sub _parse_characterstream {
85 my ($self, $fh) = @_;
86 $self->{ParseOptions}->{ParseFunc} = \&ParseStream;
87 $self->{ParseOptions}->{ParseFuncParam} = $fh;
88 $self->_parse;
89}
90
91sub _parse_bytestream {
92 my ($self, $fh) = @_;
93 $self->{ParseOptions}->{ParseFunc} = \&ParseStream;
94 $self->{ParseOptions}->{ParseFuncParam} = $fh;
95 $self->_parse;
96}
97
98
# spent 28.9s (76.6ms+28.8) within XML::SAX::ExpatXS::_parse_string which was called 5000 times, avg 5.77ms/call: # 5000 times (76.6ms+28.8s) by XML::SAX::Base::parse at line 2602 of XML/SAX/Base.pm, avg 5.77ms/call
sub _parse_string {
99500011.1ms my ($self, $str) = @_;
100500012.8ms $self->{ParseOptions}->{ParseFunc} = \&ParseString;
101500016.3ms $self->{ParseOptions}->{ParseFuncParam} = $str;
102500034.9ms500028.8s $self->_parse;
# spent 28.8s making 5000 calls to XML::SAX::ExpatXS::_parse, avg 5.76ms/call
103}
104
105sub _parse_systemid {
106 my ($self, $uri) = @_;
107 my $fh = IO::File->new($uri) or croak "ExpatXS: Can't open $uri ($!)";
108 $self->{ParseOptions}->{ParseFunc} = \&ParseStream;
109 $self->{ParseOptions}->{ParseFuncParam} = $fh;
110 $self->_parse;
111}
112
113
# spent 28.8s (612ms+28.2) within XML::SAX::ExpatXS::_parse which was called 5000 times, avg 5.76ms/call: # 5000 times (612ms+28.2s) by XML::SAX::ExpatXS::_parse_string at line 102, avg 5.76ms/call
sub _parse {
11450005.94ms my $self = shift;
115
116500014.4ms my $args = bless $self->{ParseOptions}, ref($self);
11750006.96ms delete $args->{ParseOptions};
118
119 # copy handlers over
12050007.87ms $args->{Handler} = $self->{Handler};
121500013.3ms $args->{DocumentHandler} = $self->{DocumentHandler};
12250008.46ms $args->{ContentHandler} = $self->{ContentHandler};
12350007.78ms $args->{DTDHandler} = $self->{DTDHandler};
12450008.43ms $args->{LexicalHandler} = $self->{LexicalHandler};
12550007.47ms $args->{DeclHandler} = $self->{DeclHandler};
12650007.49ms $args->{ErrorHandler} = $self->{ErrorHandler};
12750008.02ms $args->{EntityResolver} = $self->{EntityResolver};
128
12950006.85ms $args->{_State_} = 0;
13050008.69ms $args->{Context} = [];
131500014.4ms $args->{ErrorMessage} ||= '';
132500014.6ms $args->{Namespace_Stack} = [[ xml => 'http://www.w3.org/XML/1998/namespace' ]];
133500095.3ms500063.8ms $args->{Parser} = ParserCreate($args,
# spent 63.8ms making 5000 calls to XML::SAX::ExpatXS::ParserCreate, avg 13µs/call
134 $args->{Source}{Encoding}
135 || $args->{ProtocolEncoding},
136 1);
137500064.2ms500031.3ms $args->{Locator} = GetLocator($args->{Parser},
# spent 31.3ms making 5000 calls to XML::SAX::ExpatXS::GetLocator, avg 6µs/call
138 $args->{Source}{PublicId} || '',
139 $args->{Source}{SystemId} || '',
140 $args->{Source}{Encoding} || '',
141 );
142500036.7ms500012.3ms $args->{RecognizedString} = GetRecognizedString($args->{Parser});
# spent 12.3ms making 5000 calls to XML::SAX::ExpatXS::GetRecognizedString, avg 2µs/call
143500035.7ms500011.2ms $args->{ExternEnt} = GetExternEnt($args->{Parser});
# spent 11.2ms making 5000 calls to XML::SAX::ExpatXS::GetExternEnt, avg 2µs/call
144
14550007.88ms $args->{Methods} = {};
146500025.3ms5000135ms $args->get_start_element();
# spent 135ms making 5000 calls to XML::SAX::ExpatXS::Preload::get_start_element, avg 27µs/call
147500022.8ms5000126ms $args->get_end_element();
# spent 126ms making 5000 calls to XML::SAX::ExpatXS::Preload::get_end_element, avg 25µs/call
148500021.5ms5000124ms $args->get_characters();
# spent 124ms making 5000 calls to XML::SAX::ExpatXS::Preload::get_characters, avg 25µs/call
149500021.2ms5000122ms $args->get_comment();
# spent 122ms making 5000 calls to XML::SAX::ExpatXS::Preload::get_comment, avg 24µs/call
150
151 # the most common handlers are available as refs
152500043.1ms500012.7ms SetCallbacks($args->{Parser},
# spent 12.7ms making 5000 calls to XML::SAX::ExpatXS::SetCallbacks, avg 3µs/call
153 $args->{Methods}->{start_element},
154 $args->{Methods}->{end_element},
155 $args->{Methods}->{characters},
156 $args->{Methods}->{comment},
157 );
158
159500023.9ms5000255ms $args->set_document_locator($args->{Locator});
# spent 255ms making 5000 calls to XML::SAX::Base::set_document_locator, avg 51µs/call
160500027.1ms5000241ms $args->start_document({});
# spent 241ms making 5000 calls to XML::SAX::Base::start_document, avg 48µs/call
161
16250004.83ms my $result;
16350006.78s74119646.1s $result = $args->{ParseFunc}->($args->{Parser}, $args->{ParseFuncParam});
# spent 26.7s making 5000 calls to XML::SAX::ExpatXS::ParseString, avg 5.35ms/call # spent 10.6s making 185299 calls to XML::SAX::ExpatXS::Preload::__ANON__[XML/SAX/ExpatXS/Preload.pm:41], avg 57µs/call # spent 5.29s making 365598 calls to XML::SAX::ExpatXS::Preload::__ANON__[XML/SAX/ExpatXS/Preload.pm:167], avg 14µs/call # spent 3.55s making 185299 calls to XML::SAX::ExpatXS::Preload::__ANON__[XML/SAX/ExpatXS/Preload.pm:230], avg 19µs/call
164
165500064.2ms500041.3ms ParserFree($args->{Parser});
# spent 41.3ms making 5000 calls to XML::SAX::ExpatXS::ParserFree, avg 8µs/call
166
167500026.9ms5000264ms my $rv = $args->end_document({}); # end_document is still called on error
# spent 264ms making 5000 calls to XML::SAX::Base::end_document, avg 53µs/call
168
16950004.91ms croak($args->{ErrorMessage}) unless $result;
170500024.4ms return $rv;
171}
172
173sub _get_external_entity {
174 my ($self, $base, $sysid, $pubid) = @_;
175
176 # resolving with the base URI
177 if ($base and $sysid and $sysid !~ /^[a-zA-Z]+[a-zA-Z\d\+\-\.]*:/) {
178 $base =~ s/[^\/]+$//;
179 $sysid = $base . $sysid;
180 }
181
182 # user defined resolution
183 my $src = $self->resolve_entity({PublicId => $pubid,
184 SystemId => $sysid});
185 my $fh;
186 my $result;
187 my $string;
188 if (ref($src) eq 'CODE') {
189 $fh = IO::File->new($sysid)
190 or croak("Can't open external entity: $sysid\n");
191
192 } elsif (ref($src) eq 'HASH') {
193 if (defined $src->{CharacterStream}) {
194 $fh = $src->{CharacterStream};
195
196 } elsif (defined $src->{ByteStream}) {
197 $fh = $src->{ByteStream};
198
199 } elsif (defined $src->{String}) {
200 $result = $src->{String};
201 $string = 1;
202
203 } else {
204 $fh = IO::File->new($src->{SystemId})
205 or croak("Can't open external entity: $src->{SystemId}\n");
206 }
207
208 } else {
209 croak ("Invalid object returned by EntityResolver: $src\n");
210 }
211
212 unless ($string) {
213 local $/;
214 undef $/;
215 $result = <$fh>;
216 close($fh);
217 }
218 return $result;
219}
220
221sub _get_handler_methods {
222 my $self = shift;
223
224
225}
226
227113µs1;
228__END__
 
# spent 13.9ms within XML::SAX::ExpatXS::ExpatVersion which was called 5000 times, avg 3µs/call: # 5000 times (13.9ms+0s) by XML::SAX::ExpatXS::new at line 44, avg 3µs/call
sub XML::SAX::ExpatXS::ExpatVersion; # xsub
# spent 11.2ms within XML::SAX::ExpatXS::GetExternEnt which was called 5000 times, avg 2µs/call: # 5000 times (11.2ms+0s) by XML::SAX::ExpatXS::_parse at line 143, avg 2µs/call
sub XML::SAX::ExpatXS::GetExternEnt; # xsub
# spent 31.3ms within XML::SAX::ExpatXS::GetLocator which was called 5000 times, avg 6µs/call: # 5000 times (31.3ms+0s) by XML::SAX::ExpatXS::_parse at line 137, avg 6µs/call
sub XML::SAX::ExpatXS::GetLocator; # xsub
# spent 12.3ms within XML::SAX::ExpatXS::GetRecognizedString which was called 5000 times, avg 2µs/call: # 5000 times (12.3ms+0s) by XML::SAX::ExpatXS::_parse at line 142, avg 2µs/call
sub XML::SAX::ExpatXS::GetRecognizedString; # xsub
# spent 26.7s (7.34+19.4) within XML::SAX::ExpatXS::ParseString which was called 5000 times, avg 5.35ms/call: # 5000 times (7.34s+19.4s) by XML::SAX::ExpatXS::_parse at line 163, avg 5.35ms/call
sub XML::SAX::ExpatXS::ParseString; # xsub
# spent 63.8ms within XML::SAX::ExpatXS::ParserCreate which was called 5000 times, avg 13µs/call: # 5000 times (63.8ms+0s) by XML::SAX::ExpatXS::_parse at line 133, avg 13µs/call
sub XML::SAX::ExpatXS::ParserCreate; # xsub
# spent 41.3ms within XML::SAX::ExpatXS::ParserFree which was called 5000 times, avg 8µs/call: # 5000 times (41.3ms+0s) by XML::SAX::ExpatXS::_parse at line 165, avg 8µs/call
sub XML::SAX::ExpatXS::ParserFree; # xsub
# spent 12.7ms within XML::SAX::ExpatXS::SetCallbacks which was called 5000 times, avg 3µs/call: # 5000 times (12.7ms+0s) by XML::SAX::ExpatXS::_parse at line 152, avg 3µs/call
sub XML::SAX::ExpatXS::SetCallbacks; # xsub
# spent 100µs within XML::SAX::ExpatXS::bootstrap which was called: # once (100µs+0s) by DynaLoader::bootstrap at line 215 of DynaLoader.pm
sub XML::SAX::ExpatXS::bootstrap; # xsub