Filename | /usr/local/lib/perl5/site_perl/mach/5.24/HTML/Parser.pm |
Statements | Executed 4361 statements in 59.3ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
189 | 1 | 1 | 1.69s | 21.4s | parse (xsub) | HTML::Parser::
189 | 1 | 1 | 35.1ms | 52.6ms | init | HTML::Parser::
1323 | 1 | 1 | 12.3ms | 12.3ms | handler (xsub) | HTML::Parser::
189 | 1 | 1 | 5.58ms | 176ms | eof (xsub) | HTML::Parser::
189 | 1 | 1 | 4.30ms | 56.9ms | new | HTML::Parser::
189 | 1 | 1 | 3.03ms | 3.03ms | _alloc_pstate (xsub) | HTML::Parser::
378 | 1 | 1 | 1.35ms | 1.35ms | CORE:match (opcode) | HTML::Parser::
378 | 2 | 1 | 1.18ms | 1.18ms | utf8_mode (xsub) | HTML::Parser::
189 | 1 | 1 | 781µs | 781µs | marked_sections (xsub) | HTML::Parser::
1 | 1 | 1 | 51µs | 67µs | BEGIN@3 | HTML::Parser::
1 | 1 | 1 | 38µs | 182µ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 | 85µs | 2 | 82µs | # spent 67µs (51+15) within HTML::Parser::BEGIN@3 which was called:
# once (51µs+15µs) by Mail::SpamAssassin::HTML::BEGIN@30 at line 3 # spent 67µs making 1 call to HTML::Parser::BEGIN@3
# spent 15µs making 1 call to strict::import |
4 | 2 | 1.47ms | 2 | 326µs | # spent 182µs (38+144) within HTML::Parser::BEGIN@4 which was called:
# once (38µs+144µs) by Mail::SpamAssassin::HTML::BEGIN@30 at line 4 # spent 182µs making 1 call to HTML::Parser::BEGIN@4
# spent 144µs making 1 call to vars::import |
5 | |||||
6 | 1 | 2µs | $VERSION = "3.72"; | ||
7 | |||||
8 | 1 | 433µs | require HTML::Entities; | ||
9 | |||||
10 | 1 | 4µs | require XSLoader; | ||
11 | 1 | 522µs | 1 | 501µs | XSLoader::load('HTML::Parser', $VERSION); # spent 501µs making 1 call to XSLoader::load |
12 | |||||
13 | sub new | ||||
14 | # spent 56.9ms (4.30+52.6) within HTML::Parser::new which was called 189 times, avg 301µs/call:
# 189 times (4.30ms+52.6ms) by Mail::SpamAssassin::HTML::new at line 93 of Mail/SpamAssassin/HTML.pm, avg 301µs/call | ||||
15 | 189 | 476µs | my $class = shift; | ||
16 | 189 | 788µs | my $self = bless {}, $class; | ||
17 | 189 | 2.82ms | 189 | 52.6ms | return $self->init(@_); # spent 52.6ms making 189 calls to HTML::Parser::init, avg 278µs/call |
18 | } | ||||
19 | |||||
20 | |||||
21 | sub init | ||||
22 | # spent 52.6ms (35.1+17.5) within HTML::Parser::init which was called 189 times, avg 278µs/call:
# 189 times (35.1ms+17.5ms) by HTML::Parser::new at line 17, avg 278µs/call | ||||
23 | 189 | 407µs | my $self = shift; | ||
24 | 189 | 4.73ms | 189 | 3.03ms | $self->_alloc_pstate; # spent 3.03ms making 189 calls to HTML::Parser::_alloc_pstate, avg 16µs/call |
25 | |||||
26 | 189 | 1.33ms | my %arg = @_; | ||
27 | 189 | 764µs | my $api_version = delete $arg{api_version} || (@_ ? 3 : 2); | ||
28 | 189 | 446µ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 | 439µ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.16ms | if (my $h = delete $arg{handlers}) { | ||
58 | 189 | 1.99ms | $h = {@$h} if ref($h) eq "ARRAY"; | ||
59 | 189 | 9.22ms | while (my($event, $cb) = each %$h) { | ||
60 | 1323 | 21.5ms | 1323 | 12.3ms | $self->handler($event => @$cb); # spent 12.3ms making 1323 calls to HTML::Parser::handler, avg 9µs/call |
61 | } | ||||
62 | } | ||||
63 | |||||
64 | # In the end we try to assume plain attribute or handler | ||||
65 | 189 | 2.72ms | while (my($option, $val) = each %arg) { | ||
66 | 189 | 3.69ms | 378 | 1.35ms | if ($option =~ /^(\w+)_h$/) { # spent 1.35ms 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 | 781µs | $self->$option($val); # spent 781µ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 | 2µs | *end = \&text; | ||
118 | 1 | 2µs | *comment = \&text; | ||
119 | 1 | 2µs | *declaration = \&text; | ||
120 | 1 | 2µs | *process = \&text; | ||
121 | |||||
122 | 1 | 18µs | 1; | ||
123 | |||||
124 | __END__ | ||||
# spent 1.35ms within HTML::Parser::CORE:match which was called 378 times, avg 4µs/call:
# 378 times (1.35ms+0s) by HTML::Parser::init at line 66, avg 4µs/call | |||||
# spent 3.03ms within HTML::Parser::_alloc_pstate which was called 189 times, avg 16µs/call:
# 189 times (3.03ms+0s) by HTML::Parser::init at line 24, avg 16µs/call | |||||
# spent 176ms (5.58+171) within HTML::Parser::eof which was called 189 times, avg 933µs/call:
# 189 times (5.58ms+171ms) by Mail::SpamAssassin::HTML::parse at line 261 of Mail/SpamAssassin/HTML.pm, avg 933µs/call | |||||
# spent 12.3ms within HTML::Parser::handler which was called 1323 times, avg 9µs/call:
# 1323 times (12.3ms+0s) by HTML::Parser::init at line 60, avg 9µs/call | |||||
# spent 781µs within HTML::Parser::marked_sections which was called 189 times, avg 4µs/call:
# 189 times (781µs+0s) by HTML::Parser::init at line 74, avg 4µs/call | |||||
# spent 21.4s (1.69+19.7) within HTML::Parser::parse which was called 189 times, avg 113ms/call:
# 189 times (1.69s+19.7s) by Mail::SpamAssassin::HTML::parse at line 260 of Mail/SpamAssassin/HTML.pm, avg 113ms/call | |||||
# spent 1.18ms within HTML::Parser::utf8_mode which was called 378 times, avg 3µs/call:
# 189 times (664µs+0s) by Mail::SpamAssassin::HTML::parse at line 255 of Mail/SpamAssassin/HTML.pm, avg 4µs/call
# 189 times (518µs+0s) by Mail::SpamAssassin::HTML::parse at line 256 of Mail/SpamAssassin/HTML.pm, avg 3µs/call |