Filename | /usr/local/lib/perl5/site_perl/mach/5.24/HTML/Parser.pm |
Statements | Executed 4361 statements in 73.5ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
189 | 1 | 1 | 1.61s | 22.3s | parse (xsub) | HTML::Parser::
189 | 1 | 1 | 41.3ms | 60.1ms | init | HTML::Parser::
1323 | 1 | 1 | 13.5ms | 13.5ms | handler (xsub) | HTML::Parser::
189 | 1 | 1 | 5.41ms | 187ms | eof (xsub) | HTML::Parser::
189 | 1 | 1 | 4.42ms | 64.6ms | new | HTML::Parser::
189 | 1 | 1 | 3.14ms | 3.14ms | _alloc_pstate (xsub) | HTML::Parser::
378 | 1 | 1 | 1.39ms | 1.39ms | CORE:match (opcode) | HTML::Parser::
378 | 2 | 1 | 1.22ms | 1.22ms | utf8_mode (xsub) | HTML::Parser::
189 | 1 | 1 | 778µs | 778µs | marked_sections (xsub) | HTML::Parser::
1 | 1 | 1 | 39µs | 46µs | BEGIN@3 | HTML::Parser::
1 | 1 | 1 | 31µs | 133µs | BEGIN@4 | HTML::Parser::
0 | 0 | 0 | 0s | 0s | __ANON__[:48] | HTML::Parser::
0 | 0 | 0 | 0s | 0s | __ANON__[:54] | HTML::Parser::
0 | 0 | 0 | 0s | 0s | netscape_buggy_comment | HTML::Parser::
0 | 0 | 0 | 0s | 0s | parse_file | HTML::Parser::
0 | 0 | 0 | 0s | 0s | text | HTML::Parser::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | package HTML::Parser; | ||||
2 | |||||
3 | 2 | 59µs | 2 | 53µs | # spent 46µs (39+7) within HTML::Parser::BEGIN@3 which was called:
# once (39µs+7µs) by Mail::SpamAssassin::HTML::BEGIN@30 at line 3 # spent 46µs making 1 call to HTML::Parser::BEGIN@3
# spent 7µs making 1 call to strict::import |
4 | 2 | 1.44ms | 2 | 235µs | # spent 133µs (31+102) within HTML::Parser::BEGIN@4 which was called:
# once (31µs+102µs) by Mail::SpamAssassin::HTML::BEGIN@30 at line 4 # spent 133µs making 1 call to HTML::Parser::BEGIN@4
# spent 102µs making 1 call to vars::import |
5 | |||||
6 | 1 | 2µs | $VERSION = "3.72"; | ||
7 | |||||
8 | 1 | 411µs | require HTML::Entities; | ||
9 | |||||
10 | 1 | 5µs | require XSLoader; | ||
11 | 1 | 579µs | 1 | 557µs | XSLoader::load('HTML::Parser', $VERSION); # spent 557µs making 1 call to XSLoader::load |
12 | |||||
13 | sub new | ||||
14 | # spent 64.6ms (4.42+60.1) within HTML::Parser::new which was called 189 times, avg 342µs/call:
# 189 times (4.42ms+60.1ms) by Mail::SpamAssassin::HTML::new at line 93 of Mail/SpamAssassin/HTML.pm, avg 342µs/call | ||||
15 | 189 | 460µs | my $class = shift; | ||
16 | 189 | 824µs | my $self = bless {}, $class; | ||
17 | 189 | 9.47ms | 189 | 60.1ms | return $self->init(@_); # spent 60.1ms making 189 calls to HTML::Parser::init, avg 318µs/call |
18 | } | ||||
19 | |||||
20 | |||||
21 | sub init | ||||
22 | # spent 60.1ms (41.3+18.8) within HTML::Parser::init which was called 189 times, avg 318µs/call:
# 189 times (41.3ms+18.8ms) by HTML::Parser::new at line 17, avg 318µs/call | ||||
23 | 189 | 407µs | my $self = shift; | ||
24 | 189 | 4.87ms | 189 | 3.14ms | $self->_alloc_pstate; # spent 3.14ms making 189 calls to HTML::Parser::_alloc_pstate, avg 17µs/call |
25 | |||||
26 | 189 | 1.33ms | my %arg = @_; | ||
27 | 189 | 764µs | my $api_version = delete $arg{api_version} || (@_ ? 3 : 2); | ||
28 | 189 | 452µs | if ($api_version >= 4) { | ||
29 | require Carp; | ||||
30 | Carp::croak("API version $api_version not supported " . | ||||
31 | "by HTML::Parser $VERSION"); | ||||
32 | } | ||||
33 | |||||
34 | 189 | 451µs | if ($api_version < 3) { | ||
35 | # Set up method callbacks compatible with HTML-Parser-2.xx | ||||
36 | $self->handler(text => "text", "self,text,is_cdata"); | ||||
37 | $self->handler(end => "end", "self,tagname,text"); | ||||
38 | $self->handler(process => "process", "self,token0,text"); | ||||
39 | $self->handler(start => "start", | ||||
40 | "self,tagname,attr,attrseq,text"); | ||||
41 | |||||
42 | $self->handler(comment => | ||||
43 | sub { | ||||
44 | my($self, $tokens) = @_; | ||||
45 | for (@$tokens) { | ||||
46 | $self->comment($_); | ||||
47 | } | ||||
48 | }, "self,tokens"); | ||||
49 | |||||
50 | $self->handler(declaration => | ||||
51 | sub { | ||||
52 | my $self = shift; | ||||
53 | $self->declaration(substr($_[0], 2, -1)); | ||||
54 | }, "self,text"); | ||||
55 | } | ||||
56 | |||||
57 | 189 | 1.06ms | if (my $h = delete $arg{handlers}) { | ||
58 | 189 | 1.99ms | $h = {@$h} if ref($h) eq "ARRAY"; | ||
59 | 189 | 8.75ms | while (my($event, $cb) = each %$h) { | ||
60 | 1323 | 29.7ms | 1323 | 13.5ms | $self->handler($event => @$cb); # spent 13.5ms making 1323 calls to HTML::Parser::handler, avg 10µs/call |
61 | } | ||||
62 | } | ||||
63 | |||||
64 | # In the end we try to assume plain attribute or handler | ||||
65 | 189 | 2.50ms | while (my($option, $val) = each %arg) { | ||
66 | 189 | 3.71ms | 378 | 1.39ms | if ($option =~ /^(\w+)_h$/) { # spent 1.39ms making 378 calls to HTML::Parser::CORE:match, avg 4µs/call |
67 | $self->handler($1 => @$val); | ||||
68 | } | ||||
69 | elsif ($option =~ /^(text|start|end|process|declaration|comment)$/) { | ||||
70 | require Carp; | ||||
71 | Carp::croak("Bad constructor option '$option'"); | ||||
72 | } | ||||
73 | else { | ||||
74 | 189 | 2.44ms | 189 | 778µs | $self->$option($val); # spent 778µs making 189 calls to HTML::Parser::marked_sections, avg 4µs/call |
75 | } | ||||
76 | } | ||||
77 | |||||
78 | 189 | 1.85ms | return $self; | ||
79 | } | ||||
80 | |||||
81 | |||||
82 | sub parse_file | ||||
83 | { | ||||
84 | my($self, $file) = @_; | ||||
85 | my $opened; | ||||
86 | if (!ref($file) && ref(\$file) ne "GLOB") { | ||||
87 | # Assume $file is a filename | ||||
88 | local(*F); | ||||
89 | open(F, "<", $file) || return undef; | ||||
90 | binmode(F); # should we? good for byte counts | ||||
91 | $opened++; | ||||
92 | $file = *F; | ||||
93 | } | ||||
94 | my $chunk = ''; | ||||
95 | while (read($file, $chunk, 512)) { | ||||
96 | $self->parse($chunk) || last; | ||||
97 | } | ||||
98 | close($file) if $opened; | ||||
99 | $self->eof; | ||||
100 | } | ||||
101 | |||||
102 | |||||
103 | sub netscape_buggy_comment # legacy | ||||
104 | { | ||||
105 | my $self = shift; | ||||
106 | require Carp; | ||||
107 | Carp::carp("netscape_buggy_comment() is deprecated. " . | ||||
108 | "Please use the strict_comment() method instead"); | ||||
109 | my $old = !$self->strict_comment; | ||||
110 | $self->strict_comment(!shift) if @_; | ||||
111 | return $old; | ||||
112 | } | ||||
113 | |||||
114 | # set up method stubs | ||||
115 | sub text { } | ||||
116 | 1 | 4µs | *start = \&text; | ||
117 | 1 | 3µs | *end = \&text; | ||
118 | 1 | 3µs | *comment = \&text; | ||
119 | 1 | 3µs | *declaration = \&text; | ||
120 | 1 | 3µs | *process = \&text; | ||
121 | |||||
122 | 1 | 23µs | 1; | ||
123 | |||||
124 | __END__ | ||||
# spent 1.39ms within HTML::Parser::CORE:match which was called 378 times, avg 4µs/call:
# 378 times (1.39ms+0s) by HTML::Parser::init at line 66, avg 4µs/call | |||||
# spent 3.14ms within HTML::Parser::_alloc_pstate which was called 189 times, avg 17µs/call:
# 189 times (3.14ms+0s) by HTML::Parser::init at line 24, avg 17µs/call | |||||
# spent 187ms (5.41+182) within HTML::Parser::eof which was called 189 times, avg 991µs/call:
# 189 times (5.41ms+182ms) by Mail::SpamAssassin::HTML::parse at line 261 of Mail/SpamAssassin/HTML.pm, avg 991µs/call | |||||
# spent 13.5ms within HTML::Parser::handler which was called 1323 times, avg 10µs/call:
# 1323 times (13.5ms+0s) by HTML::Parser::init at line 60, avg 10µs/call | |||||
# spent 778µs within HTML::Parser::marked_sections which was called 189 times, avg 4µs/call:
# 189 times (778µs+0s) by HTML::Parser::init at line 74, avg 4µs/call | |||||
# spent 22.3s (1.61+20.7) within HTML::Parser::parse which was called 189 times, avg 118ms/call:
# 189 times (1.61s+20.7s) by Mail::SpamAssassin::HTML::parse at line 260 of Mail/SpamAssassin/HTML.pm, avg 118ms/call | |||||
# spent 1.22ms within HTML::Parser::utf8_mode which was called 378 times, avg 3µs/call:
# 189 times (682µs+0s) by Mail::SpamAssassin::HTML::parse at line 255 of Mail/SpamAssassin/HTML.pm, avg 4µs/call
# 189 times (536µs+0s) by Mail::SpamAssassin::HTML::parse at line 256 of Mail/SpamAssassin/HTML.pm, avg 3µs/call |