Filename | /usr/lib/perl5/XML/SAX/ExpatXS.pm |
Statements | Executed 270030 statements in 7.88s |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
5000 | 1 | 1 | 7.34s | 26.7s | ParseString (xsub) | XML::SAX::ExpatXS::
5000 | 1 | 1 | 612ms | 28.8s | _parse | XML::SAX::ExpatXS::
5000 | 1 | 1 | 287ms | 424ms | new | XML::SAX::ExpatXS::
5000 | 1 | 1 | 76.6ms | 28.9s | _parse_string | XML::SAX::ExpatXS::
5000 | 1 | 1 | 63.8ms | 63.8ms | ParserCreate (xsub) | XML::SAX::ExpatXS::
5000 | 1 | 1 | 41.3ms | 41.3ms | ParserFree (xsub) | XML::SAX::ExpatXS::
5000 | 1 | 1 | 33.9ms | 33.9ms | set_feature | XML::SAX::ExpatXS::
5000 | 1 | 1 | 31.3ms | 31.3ms | GetLocator (xsub) | XML::SAX::ExpatXS::
5000 | 1 | 1 | 13.9ms | 13.9ms | ExpatVersion (xsub) | XML::SAX::ExpatXS::
5000 | 1 | 1 | 12.7ms | 12.7ms | SetCallbacks (xsub) | XML::SAX::ExpatXS::
5000 | 1 | 1 | 12.3ms | 12.3ms | GetRecognizedString (xsub) | XML::SAX::ExpatXS::
5000 | 1 | 1 | 11.2ms | 11.2ms | GetExternEnt (xsub) | XML::SAX::ExpatXS::
1 | 1 | 1 | 3.01ms | 3.10ms | BEGIN@6 | XML::SAX::ExpatXS::
1 | 1 | 1 | 1.59ms | 2.58ms | BEGIN@5 | XML::SAX::ExpatXS::
1 | 1 | 1 | 100µs | 100µs | bootstrap (xsub) | XML::SAX::ExpatXS::
1 | 1 | 1 | 26µs | 32µs | BEGIN@2 | XML::SAX::ExpatXS::
1 | 1 | 1 | 19µs | 378µs | BEGIN@10 | XML::SAX::ExpatXS::
1 | 1 | 1 | 17µs | 93µs | BEGIN@9 | XML::SAX::ExpatXS::
1 | 1 | 1 | 16µs | 16µs | BEGIN@7 | XML::SAX::ExpatXS::
1 | 1 | 1 | 15µs | 90µs | BEGIN@3 | XML::SAX::ExpatXS::
1 | 1 | 1 | 8µs | 8µs | BEGIN@8 | XML::SAX::ExpatXS::
0 | 0 | 0 | 0s | 0s | _get_external_entity | XML::SAX::ExpatXS::
0 | 0 | 0 | 0s | 0s | _get_handler_methods | XML::SAX::ExpatXS::
0 | 0 | 0 | 0s | 0s | _parse_bytestream | XML::SAX::ExpatXS::
0 | 0 | 0 | 0s | 0s | _parse_characterstream | XML::SAX::ExpatXS::
0 | 0 | 0 | 0s | 0s | _parse_systemid | XML::SAX::ExpatXS::
0 | 0 | 0 | 0s | 0s | get_feature | XML::SAX::ExpatXS::
0 | 0 | 0 | 0s | 0s | get_features | XML::SAX::ExpatXS::
0 | 0 | 0 | 0s | 0s | supported_features | XML::SAX::ExpatXS::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | package XML::SAX::ExpatXS; | ||||
2 | 3 | 59µs | 2 | 38µ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 # spent 32µs making 1 call to XML::SAX::ExpatXS::BEGIN@2
# spent 6µs making 1 call to strict::import |
3 | 3 | 50µs | 2 | 165µ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 # spent 90µs making 1 call to XML::SAX::ExpatXS::BEGIN@3
# spent 75µs making 1 call to vars::import |
4 | |||||
5 | 3 | 166µs | 1 | 2.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 # spent 2.58ms making 1 call to XML::SAX::ExpatXS::BEGIN@5 |
6 | 3 | 170µs | 1 | 3.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 # spent 3.10ms making 1 call to XML::SAX::ExpatXS::BEGIN@6 |
7 | 3 | 42µs | 1 | 16µ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 # spent 16µs making 1 call to XML::SAX::ExpatXS::BEGIN@7 |
8 | 3 | 36µs | 1 | 8µ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 # spent 8µs making 1 call to XML::SAX::ExpatXS::BEGIN@8 |
9 | 3 | 42µs | 2 | 169µ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 # spent 93µs making 1 call to XML::SAX::ExpatXS::BEGIN@9
# spent 76µs making 1 call to Exporter::import |
10 | 3 | 1.50ms | 2 | 737µ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 # spent 378µs making 1 call to XML::SAX::ExpatXS::BEGIN@10
# spent 359µs making 1 call to Exporter::import |
11 | |||||
12 | 1 | 1µs | $VERSION = '1.31'; | ||
13 | 1 | 24µs | @ISA = qw(DynaLoader XML::SAX::Base XML::SAX::ExpatXS::Preload); | ||
14 | |||||
15 | 1 | 10µs | 1 | 550µs | XML::SAX::ExpatXS->bootstrap($VERSION); # spent 550µs making 1 call to DynaLoader::bootstrap |
16 | |||||
17 | 1 | 21µs | my @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 | ); | ||||
29 | 1 | 15µs | my @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 | ||||
37 | 5000 | 7.72ms | my $proto = shift; | ||
38 | 5000 | 23.5ms | my $options = ($#_ == 0) ? shift : { @_ }; | ||
39 | |||||
40 | 5000 | 13.4ms | foreach (@features) { | ||
41 | 50000 | 156ms | $options->{Features}->{$_->[0]} = $_->[1]; | ||
42 | } | ||||
43 | |||||
44 | 5000 | 42.0ms | 5000 | 13.9ms | $options->{ExpatVersion} = ExpatVersion(); # spent 13.9ms making 5000 calls to XML::SAX::ExpatXS::ExpatVersion, avg 3µs/call |
45 | |||||
46 | 5000 | 57.6ms | 5000 | 123ms | return $proto->SUPER::new($options); # spent 123ms making 5000 calls to XML::SAX::Base::new, avg 25µs/call |
47 | } | ||||
48 | |||||
49 | sub 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 | ||||
60 | 5000 | 8.77ms | my ($self, $feat, $val) = @_; | ||
61 | 5000 | 32.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 | |||||
69 | sub get_features { | ||||
70 | my $self = shift; | ||||
71 | return %{$self->{Features}}; | ||||
72 | } | ||||
73 | |||||
74 | sub supported_features { | ||||
75 | my $self = shift; | ||||
76 | |||||
77 | return @supported_features; | ||||
78 | } | ||||
79 | |||||
80 | #------------------------------------------------------------ | ||||
81 | # internal methods | ||||
82 | #------------------------------------------------------------ | ||||
83 | |||||
84 | sub _parse_characterstream { | ||||
85 | my ($self, $fh) = @_; | ||||
86 | $self->{ParseOptions}->{ParseFunc} = \&ParseStream; | ||||
87 | $self->{ParseOptions}->{ParseFuncParam} = $fh; | ||||
88 | $self->_parse; | ||||
89 | } | ||||
90 | |||||
91 | sub _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 | ||||
99 | 5000 | 11.1ms | my ($self, $str) = @_; | ||
100 | 5000 | 12.8ms | $self->{ParseOptions}->{ParseFunc} = \&ParseString; | ||
101 | 5000 | 16.3ms | $self->{ParseOptions}->{ParseFuncParam} = $str; | ||
102 | 5000 | 34.9ms | 5000 | 28.8s | $self->_parse; # spent 28.8s making 5000 calls to XML::SAX::ExpatXS::_parse, avg 5.76ms/call |
103 | } | ||||
104 | |||||
105 | sub _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 | ||||
114 | 5000 | 5.94ms | my $self = shift; | ||
115 | |||||
116 | 5000 | 14.4ms | my $args = bless $self->{ParseOptions}, ref($self); | ||
117 | 5000 | 6.96ms | delete $args->{ParseOptions}; | ||
118 | |||||
119 | # copy handlers over | ||||
120 | 5000 | 7.87ms | $args->{Handler} = $self->{Handler}; | ||
121 | 5000 | 13.3ms | $args->{DocumentHandler} = $self->{DocumentHandler}; | ||
122 | 5000 | 8.46ms | $args->{ContentHandler} = $self->{ContentHandler}; | ||
123 | 5000 | 7.78ms | $args->{DTDHandler} = $self->{DTDHandler}; | ||
124 | 5000 | 8.43ms | $args->{LexicalHandler} = $self->{LexicalHandler}; | ||
125 | 5000 | 7.47ms | $args->{DeclHandler} = $self->{DeclHandler}; | ||
126 | 5000 | 7.49ms | $args->{ErrorHandler} = $self->{ErrorHandler}; | ||
127 | 5000 | 8.02ms | $args->{EntityResolver} = $self->{EntityResolver}; | ||
128 | |||||
129 | 5000 | 6.85ms | $args->{_State_} = 0; | ||
130 | 5000 | 8.69ms | $args->{Context} = []; | ||
131 | 5000 | 14.4ms | $args->{ErrorMessage} ||= ''; | ||
132 | 5000 | 14.6ms | $args->{Namespace_Stack} = [[ xml => 'http://www.w3.org/XML/1998/namespace' ]]; | ||
133 | 5000 | 95.3ms | 5000 | 63.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); | ||||
137 | 5000 | 64.2ms | 5000 | 31.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 | ); | ||||
142 | 5000 | 36.7ms | 5000 | 12.3ms | $args->{RecognizedString} = GetRecognizedString($args->{Parser}); # spent 12.3ms making 5000 calls to XML::SAX::ExpatXS::GetRecognizedString, avg 2µs/call |
143 | 5000 | 35.7ms | 5000 | 11.2ms | $args->{ExternEnt} = GetExternEnt($args->{Parser}); # spent 11.2ms making 5000 calls to XML::SAX::ExpatXS::GetExternEnt, avg 2µs/call |
144 | |||||
145 | 5000 | 7.88ms | $args->{Methods} = {}; | ||
146 | 5000 | 25.3ms | 5000 | 135ms | $args->get_start_element(); # spent 135ms making 5000 calls to XML::SAX::ExpatXS::Preload::get_start_element, avg 27µs/call |
147 | 5000 | 22.8ms | 5000 | 126ms | $args->get_end_element(); # spent 126ms making 5000 calls to XML::SAX::ExpatXS::Preload::get_end_element, avg 25µs/call |
148 | 5000 | 21.5ms | 5000 | 124ms | $args->get_characters(); # spent 124ms making 5000 calls to XML::SAX::ExpatXS::Preload::get_characters, avg 25µs/call |
149 | 5000 | 21.2ms | 5000 | 122ms | $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 | ||||
152 | 5000 | 43.1ms | 5000 | 12.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 | |||||
159 | 5000 | 23.9ms | 5000 | 255ms | $args->set_document_locator($args->{Locator}); # spent 255ms making 5000 calls to XML::SAX::Base::set_document_locator, avg 51µs/call |
160 | 5000 | 27.1ms | 5000 | 241ms | $args->start_document({}); # spent 241ms making 5000 calls to XML::SAX::Base::start_document, avg 48µs/call |
161 | |||||
162 | 5000 | 4.83ms | my $result; | ||
163 | 5000 | 6.78s | 741196 | 46.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 | |||||
165 | 5000 | 64.2ms | 5000 | 41.3ms | ParserFree($args->{Parser}); # spent 41.3ms making 5000 calls to XML::SAX::ExpatXS::ParserFree, avg 8µs/call |
166 | |||||
167 | 5000 | 26.9ms | 5000 | 264ms | 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 | |||||
169 | 5000 | 4.91ms | croak($args->{ErrorMessage}) unless $result; | ||
170 | 5000 | 24.4ms | return $rv; | ||
171 | } | ||||
172 | |||||
173 | sub _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 | |||||
221 | sub _get_handler_methods { | ||||
222 | my $self = shift; | ||||
223 | |||||
224 | |||||
225 | } | ||||
226 | |||||
227 | 1 | 13µs | 1; | ||
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 | |||||
# 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 | |||||
# 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 | |||||
# 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 | |||||
# 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 | |||||
# 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 | |||||
# 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 | |||||
# 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 | |||||
# spent 100µs within XML::SAX::ExpatXS::bootstrap which was called:
# once (100µs+0s) by DynaLoader::bootstrap at line 215 of DynaLoader.pm |