← Index
NYTProf Performance Profile   « line view »
For /usr/local/bin/sa-learn
  Run on Sun Nov 5 03:09:29 2017
Reported on Mon Nov 6 13:20:47 2017

Filename/usr/local/lib/perl5/site_perl/mach/5.24/HTML/Parser.pm
StatementsExecuted 4361 statements in 73.5ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
189111.61s22.3sHTML::Parser::::parseHTML::Parser::parse (xsub)
1891141.3ms60.1msHTML::Parser::::initHTML::Parser::init
13231113.5ms13.5msHTML::Parser::::handlerHTML::Parser::handler (xsub)
189115.41ms187msHTML::Parser::::eofHTML::Parser::eof (xsub)
189114.42ms64.6msHTML::Parser::::newHTML::Parser::new
189113.14ms3.14msHTML::Parser::::_alloc_pstateHTML::Parser::_alloc_pstate (xsub)
378111.39ms1.39msHTML::Parser::::CORE:matchHTML::Parser::CORE:match (opcode)
378211.22ms1.22msHTML::Parser::::utf8_modeHTML::Parser::utf8_mode (xsub)
18911778µs778µsHTML::Parser::::marked_sectionsHTML::Parser::marked_sections (xsub)
11139µs46µsHTML::Parser::::BEGIN@3HTML::Parser::BEGIN@3
11131µs133µsHTML::Parser::::BEGIN@4HTML::Parser::BEGIN@4
0000s0sHTML::Parser::::__ANON__[:48]HTML::Parser::__ANON__[:48]
0000s0sHTML::Parser::::__ANON__[:54]HTML::Parser::__ANON__[:54]
0000s0sHTML::Parser::::netscape_buggy_commentHTML::Parser::netscape_buggy_comment
0000s0sHTML::Parser::::parse_fileHTML::Parser::parse_file
0000s0sHTML::Parser::::textHTML::Parser::text
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package HTML::Parser;
2
3259µs253µ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
use strict;
# spent 46µs making 1 call to HTML::Parser::BEGIN@3 # spent 7µs making 1 call to strict::import
421.44ms2235µ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
use vars qw($VERSION @ISA);
# spent 133µs making 1 call to HTML::Parser::BEGIN@4 # spent 102µs making 1 call to vars::import
5
612µs$VERSION = "3.72";
7
81411µsrequire HTML::Entities;
9
1015µsrequire XSLoader;
111579µs1557µsXSLoader::load('HTML::Parser', $VERSION);
# spent 557µs making 1 call to XSLoader::load
12
13sub 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
{
15189460µs my $class = shift;
16189824µs my $self = bless {}, $class;
171899.47ms18960.1ms return $self->init(@_);
# spent 60.1ms making 189 calls to HTML::Parser::init, avg 318µs/call
18}
19
20
21sub 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
{
23189407µs my $self = shift;
241894.87ms1893.14ms $self->_alloc_pstate;
# spent 3.14ms making 189 calls to HTML::Parser::_alloc_pstate, avg 17µs/call
25
261891.33ms my %arg = @_;
27189764µs my $api_version = delete $arg{api_version} || (@_ ? 3 : 2);
28189452µs if ($api_version >= 4) {
29 require Carp;
30 Carp::croak("API version $api_version not supported " .
31 "by HTML::Parser $VERSION");
32 }
33
34189451µ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
571891.06ms if (my $h = delete $arg{handlers}) {
581891.99ms $h = {@$h} if ref($h) eq "ARRAY";
591898.75ms while (my($event, $cb) = each %$h) {
60132329.7ms132313.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
651892.50ms while (my($option, $val) = each %arg) {
661893.71ms3781.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 {
741892.44ms189778µs $self->$option($val);
# spent 778µs making 189 calls to HTML::Parser::marked_sections, avg 4µs/call
75 }
76 }
77
781891.85ms return $self;
79}
80
81
82sub 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
103sub 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
115sub text { }
11614µs*start = \&text;
11713µs*end = \&text;
11813µs*comment = \&text;
11913µs*declaration = \&text;
12013µs*process = \&text;
121
122123µs1;
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
sub HTML::Parser::CORE:match; # opcode
# 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
sub HTML::Parser::_alloc_pstate; # xsub
# 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
sub HTML::Parser::eof; # xsub
# 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
sub HTML::Parser::handler; # xsub
# 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
sub HTML::Parser::marked_sections; # xsub
# 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
sub HTML::Parser::parse; # xsub
# 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
sub HTML::Parser::utf8_mode; # xsub