File | /usr/local/lib/perl5/site_perl/5.10.1/darwin-2level/XML/LibXML/SAX.pm |
Statements Executed | 68 |
Statement Execution Time | 836µs |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
1 | 1 | 1 | 13.0ms | 13.0ms | BEGIN@18 | XML::LibXML::SAX::
1 | 1 | 1 | 8.28ms | 21.4ms | BEGIN@17 | XML::LibXML::SAX::
3 | 1 | 1 | 83µs | 3.80ms | _parse_string | XML::LibXML::SAX::
3 | 1 | 1 | 66µs | 3.59ms | _parse | XML::LibXML::SAX::
1 | 1 | 1 | 18µs | 22µs | BEGIN@12 | XML::LibXML::SAX::
1 | 1 | 1 | 14µs | 161µs | BEGIN@23 | XML::LibXML::SAX::
1 | 1 | 1 | 12µs | 81µs | BEGIN@20 | XML::LibXML::SAX::
1 | 1 | 1 | 9µs | 57µs | BEGIN@22 | XML::LibXML::SAX::
1 | 1 | 1 | 9µs | 45µs | BEGIN@13 | 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 | 36µs | 2 | 25µs | # spent 22µs (18+3) within XML::LibXML::SAX::BEGIN@12 which was called
# once (18µs+3µs) by XML::SAX::ParserFactory::parser at line 12 # spent 22µs making 1 call to XML::LibXML::SAX::BEGIN@12
# spent 3µs making 1 call to strict::import |
13 | 3 | 34µs | 2 | 82µs | # spent 45µs (9+36) within XML::LibXML::SAX::BEGIN@13 which was called
# once (9µs+36µs) by XML::SAX::ParserFactory::parser at line 13 # spent 45µs making 1 call to XML::LibXML::SAX::BEGIN@13
# spent 36µs making 1 call to vars::import |
14 | |||||
15 | 1 | 600ns | $VERSION = "1.70"; # VERSION TEMPLATE: DO NOT CHANGE | ||
16 | |||||
17 | 3 | 127µs | 2 | 21.6ms | # spent 21.4ms (8.28+13.1) within XML::LibXML::SAX::BEGIN@17 which was called
# once (8.28ms+13.1ms) by XML::SAX::ParserFactory::parser at line 17 # spent 21.4ms making 1 call to XML::LibXML::SAX::BEGIN@17
# spent 162µs making 1 call to XML::LibXML::import |
18 | 3 | 142µs | 1 | 13.0ms | # spent 13.0ms (13.0+48µs) within XML::LibXML::SAX::BEGIN@18 which was called
# once (13.0ms+48µs) by XML::SAX::ParserFactory::parser at line 18 # spent 13.0ms making 1 call to XML::LibXML::SAX::BEGIN@18 |
19 | |||||
20 | 3 | 26µs | 2 | 150µs | # spent 81µs (12+69) within XML::LibXML::SAX::BEGIN@20 which was called
# once (12µs+69µs) by XML::SAX::ParserFactory::parser at line 20 # spent 81µs making 1 call to XML::LibXML::SAX::BEGIN@20
# spent 69µs making 1 call to base::import |
21 | |||||
22 | 3 | 22µs | 2 | 106µs | # spent 57µs (9+48) within XML::LibXML::SAX::BEGIN@22 which was called
# once (9µs+48µs) by XML::SAX::ParserFactory::parser at line 22 # spent 57µs making 1 call to XML::LibXML::SAX::BEGIN@22
# spent 48µs making 1 call to Exporter::import |
23 | 3 | 321µs | 2 | 308µs | # spent 161µs (14+147) within XML::LibXML::SAX::BEGIN@23 which was called
# once (14µs+147µs) by XML::SAX::ParserFactory::parser at line 23 # spent 161µs making 1 call to XML::LibXML::SAX::BEGIN@23
# spent 147µ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 3.80ms (83µs+3.71) within XML::LibXML::SAX::_parse_string which was called 3 times, avg 1.27ms/call:
# 3 times (83µs+3.71ms) by XML::SAX::Base::parse at line 2602 of XML/SAX/Base.pm, avg 1.27ms/call | ||||
46 | 18 | 71µs | my ( $self, $string ) = @_; | ||
47 | # $self->{ParserOptions}{LibParser} = XML::LibXML->new; | ||||
48 | $self->{ParserOptions}{LibParser} = XML::LibXML->new() unless defined $self->{ParserOptions}{LibParser}; # spent 36µs making 3 calls to XML::LibXML::new, avg 12µs/call | ||||
49 | $self->{ParserOptions}{ParseFunc} = \&XML::LibXML::parse_string; | ||||
50 | $self->{ParserOptions}{ParseFuncParam} = $string; | ||||
51 | $self->_parse; # spent 3.59ms making 3 calls to XML::LibXML::SAX::_parse, avg 1.20ms/call | ||||
52 | return $self->end_document({}); # spent 88µs making 3 calls to XML::SAX::Base::end_document, avg 30µ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 3.59ms (66µs+3.52) within XML::LibXML::SAX::_parse which was called 3 times, avg 1.20ms/call:
# 3 times (66µs+3.52ms) by XML::LibXML::SAX::_parse_string at line 51, avg 1.20ms/call | ||||
75 | 27 | 53µs | my $self = shift; | ||
76 | my $args = bless $self->{ParserOptions}, ref($self); | ||||
77 | |||||
78 | $args->{LibParser}->set_handler( $self ); # spent 21µs making 3 calls to XML::LibXML::set_handler, avg 7µs/call | ||||
79 | eval { | ||||
80 | $args->{ParseFunc}->($args->{LibParser}, $args->{ParseFuncParam}); # spent 3.49ms making 3 calls to XML::LibXML::parse_string, avg 1.16ms/call | ||||
81 | }; | ||||
82 | |||||
83 | 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 | $args->{LibParser}->set_handler( undef ); # spent 15µs making 3 calls to XML::LibXML::set_handler, avg 5µs/call | ||||
89 | if ( $@ ) { | ||||
90 | croak $@; | ||||
91 | } | ||||
92 | return; | ||||
93 | } | ||||
94 | |||||
95 | |||||
96 | 1 | 4µs | 1; | ||
97 |