File | /usr/local/lib/perl5/site_perl/5.10.1/darwin-2level/XML/LibXML/SAX.pm |
Statements Executed | 638 |
Statement Execution Time | 11.3ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
1 | 1 | 1 | 28.8ms | 253ms | BEGIN@17 | XML::LibXML::SAX::
1 | 1 | 1 | 13.7ms | 13.8ms | BEGIN@18 | XML::LibXML::SAX::
41 | 1 | 1 | 1.31ms | 66.9ms | _parse_string | XML::LibXML::SAX::
41 | 1 | 1 | 1.08ms | 63.8ms | _parse | XML::LibXML::SAX::
1 | 1 | 1 | 34µs | 44µs | BEGIN@12 | XML::LibXML::SAX::
1 | 1 | 1 | 15µs | 88µs | BEGIN@13 | XML::LibXML::SAX::
1 | 1 | 1 | 14µs | 156µs | BEGIN@23 | XML::LibXML::SAX::
1 | 1 | 1 | 12µs | 84µs | BEGIN@20 | XML::LibXML::SAX::
1 | 1 | 1 | 10µs | 66µs | BEGIN@22 | XML::LibXML::SAX::
0 | 0 | 0 | 0s | 0s | CLONE_SKIP | XML::LibXML::SAX::
0 | 0 | 0 | 0s | 0s | _parse_bytestream | XML::LibXML::SAX::
0 | 0 | 0 | 0s | 0s | _parse_characterstream | XML::LibXML::SAX::
0 | 0 | 0 | 0s | 0s | _parse_systemid | XML::LibXML::SAX::
0 | 0 | 0 | 0s | 0s | parse_chunk | XML::LibXML::SAX::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | # $Id: SAX.pm 785 2009-07-16 14:17:46Z pajas $ | ||||
2 | # | ||||
3 | # This is free software, you may use it and distribute it under the same terms as | ||||
4 | # Perl itself. | ||||
5 | # | ||||
6 | # Copyright 2001-2003 AxKit.com Ltd., 2002-2006 Christian Glahn, 2006-2009 Petr Pajas | ||||
7 | # | ||||
8 | # | ||||
9 | |||||
10 | package XML::LibXML::SAX; | ||||
11 | |||||
12 | 3 | 56µs | 2 | 54µs | # spent 44µs (34+10) within XML::LibXML::SAX::BEGIN@12 which was called
# once (34µs+10µs) by XML::SAX::ParserFactory::parser at line 12 # spent 44µs making 1 call to XML::LibXML::SAX::BEGIN@12
# spent 10µs making 1 call to strict::import |
13 | 3 | 61µs | 2 | 160µs | # spent 88µs (15+73) within XML::LibXML::SAX::BEGIN@13 which was called
# once (15µs+73µs) by XML::SAX::ParserFactory::parser at line 13 # spent 88µs making 1 call to XML::LibXML::SAX::BEGIN@13
# spent 73µs making 1 call to vars::import |
14 | |||||
15 | 1 | 700ns | $VERSION = "1.70"; # VERSION TEMPLATE: DO NOT CHANGE | ||
16 | |||||
17 | 3 | 8.60ms | 2 | 253ms | # spent 253ms (28.8+224) within XML::LibXML::SAX::BEGIN@17 which was called
# once (28.8ms+224ms) by XML::SAX::ParserFactory::parser at line 17 # spent 253ms making 1 call to XML::LibXML::SAX::BEGIN@17
# spent 272µs making 1 call to XML::LibXML::import |
18 | 3 | 198µs | 1 | 13.8ms | # spent 13.8ms (13.7+80µs) within XML::LibXML::SAX::BEGIN@18 which was called
# once (13.7ms+80µs) by XML::SAX::ParserFactory::parser at line 18 # spent 13.8ms making 1 call to XML::LibXML::SAX::BEGIN@18 |
19 | |||||
20 | 3 | 26µs | 2 | 156µs | # spent 84µs (12+72) within XML::LibXML::SAX::BEGIN@20 which was called
# once (12µs+72µs) by XML::SAX::ParserFactory::parser at line 20 # spent 84µs making 1 call to XML::LibXML::SAX::BEGIN@20
# spent 72µs making 1 call to base::import |
21 | |||||
22 | 3 | 23µs | 2 | 121µs | # spent 66µs (10+56) within XML::LibXML::SAX::BEGIN@22 which was called
# once (10µs+56µs) by XML::SAX::ParserFactory::parser at line 22 # spent 66µs making 1 call to XML::LibXML::SAX::BEGIN@22
# spent 56µs making 1 call to Exporter::import |
23 | 3 | 316µs | 2 | 298µs | # spent 156µs (14+142) within XML::LibXML::SAX::BEGIN@23 which was called
# once (14µs+142µs) by XML::SAX::ParserFactory::parser at line 23 # spent 156µs making 1 call to XML::LibXML::SAX::BEGIN@23
# spent 142µs making 1 call to Exporter::import |
24 | |||||
25 | sub CLONE_SKIP { | ||||
26 | return $XML::LibXML::__threads_shared ? 0 : 1; | ||||
27 | } | ||||
28 | |||||
29 | sub _parse_characterstream { | ||||
30 | my ( $self, $fh ) = @_; | ||||
31 | # this my catch the xml decl, so the parser won't get confused about | ||||
32 | # a possibly wrong encoding. | ||||
33 | croak( "not implemented yet" ); | ||||
34 | } | ||||
35 | |||||
36 | sub _parse_bytestream { | ||||
37 | my ( $self, $fh ) = @_; | ||||
38 | $self->{ParserOptions}{LibParser} = XML::LibXML->new; | ||||
39 | $self->{ParserOptions}{ParseFunc} = \&XML::LibXML::parse_fh; | ||||
40 | $self->{ParserOptions}{ParseFuncParam} = $fh; | ||||
41 | $self->_parse; | ||||
42 | return $self->end_document({}); | ||||
43 | } | ||||
44 | |||||
45 | # spent 66.9ms (1.31+65.6) within XML::LibXML::SAX::_parse_string which was called 41 times, avg 1.63ms/call:
# 41 times (1.31ms+65.6ms) by XML::SAX::Base::parse at line 2602 of XML/SAX/Base.pm, avg 1.63ms/call | ||||
46 | 41 | 93µs | my ( $self, $string ) = @_; | ||
47 | # $self->{ParserOptions}{LibParser} = XML::LibXML->new; | ||||
48 | 41 | 408µs | 41 | 439µs | $self->{ParserOptions}{LibParser} = XML::LibXML->new() unless defined $self->{ParserOptions}{LibParser}; # spent 439µs making 41 calls to XML::LibXML::new, avg 11µs/call |
49 | 41 | 141µs | $self->{ParserOptions}{ParseFunc} = \&XML::LibXML::parse_string; | ||
50 | 41 | 99µs | $self->{ParserOptions}{ParseFuncParam} = $string; | ||
51 | 41 | 159µs | 41 | 63.8ms | $self->_parse; # spent 63.8ms making 41 calls to XML::LibXML::SAX::_parse, avg 1.56ms/call |
52 | 41 | 268µs | 41 | 1.28ms | return $self->end_document({}); # spent 1.28ms making 41 calls to XML::SAX::Base::end_document, avg 31µs/call |
53 | } | ||||
54 | |||||
55 | sub _parse_systemid { | ||||
56 | my $self = shift; | ||||
57 | $self->{ParserOptions}{LibParser} = XML::LibXML->new; | ||||
58 | $self->{ParserOptions}{ParseFunc} = \&XML::LibXML::parse_file; | ||||
59 | $self->{ParserOptions}{ParseFuncParam} = shift; | ||||
60 | $self->_parse; | ||||
61 | return $self->end_document({}); | ||||
62 | } | ||||
63 | |||||
64 | sub parse_chunk { | ||||
65 | my ( $self, $chunk ) = @_; | ||||
66 | $self->{ParserOptions}{LibParser} = XML::LibXML->new; | ||||
67 | $self->{ParserOptions}{ParseFunc} = \&XML::LibXML::parse_xml_chunk; | ||||
68 | $self->{ParserOptions}{LibParser}->{IS_FILTER}=1; # a hack to prevent parse_xml_chunk from issuing end_document | ||||
69 | $self->{ParserOptions}{ParseFuncParam} = $chunk; | ||||
70 | $self->_parse; | ||||
71 | return; | ||||
72 | } | ||||
73 | |||||
74 | # spent 63.8ms (1.08+62.8) within XML::LibXML::SAX::_parse which was called 41 times, avg 1.56ms/call:
# 41 times (1.08ms+62.8ms) by XML::LibXML::SAX::_parse_string at line 51, avg 1.56ms/call | ||||
75 | 41 | 39µs | my $self = shift; | ||
76 | 41 | 95µs | my $args = bless $self->{ParserOptions}, ref($self); | ||
77 | |||||
78 | 41 | 170µs | 41 | 350µs | $args->{LibParser}->set_handler( $self ); # spent 350µs making 41 calls to XML::LibXML::set_handler, avg 9µs/call |
79 | 41 | 40µs | eval { | ||
80 | 41 | 168µs | 41 | 62.2ms | $args->{ParseFunc}->($args->{LibParser}, $args->{ParseFuncParam}); # spent 62.2ms making 41 calls to XML::LibXML::parse_string, avg 1.52ms/call |
81 | }; | ||||
82 | |||||
83 | 41 | 95µs | if ( $args->{LibParser}->{SAX}->{State} == 1 ) { | ||
84 | croak( "SAX Exception not implemented, yet; Data ended before document ended\n" ); | ||||
85 | } | ||||
86 | |||||
87 | # break a possible circular reference | ||||
88 | 41 | 109µs | 41 | 232µs | $args->{LibParser}->set_handler( undef ); # spent 232µs making 41 calls to XML::LibXML::set_handler, avg 6µs/call |
89 | 41 | 15µs | if ( $@ ) { | ||
90 | croak $@; | ||||
91 | } | ||||
92 | 41 | 131µs | return; | ||
93 | } | ||||
94 | |||||
95 | |||||
96 | 1 | 4µs | 1; | ||
97 |