← Index
NYTProf Performance Profile   « line view »
For /usr/local/bin/sa-learn
  Run on Tue Nov 7 05:38:10 2017
Reported on Tue Nov 7 06:16:02 2017

Filename/usr/local/lib/perl5/site_perl/mach/5.24/HTML/Parser.pm
StatementsExecuted 4384 statements in 72.9ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
190111.64s20.1sHTML::Parser::::parseHTML::Parser::parse (xsub)
1901148.8ms66.3msHTML::Parser::::initHTML::Parser::init
13301112.6ms12.6msHTML::Parser::::handlerHTML::Parser::handler (xsub)
190115.40ms162msHTML::Parser::::eofHTML::Parser::eof (xsub)
190114.18ms70.5msHTML::Parser::::newHTML::Parser::new
190112.75ms2.75msHTML::Parser::::_alloc_pstateHTML::Parser::_alloc_pstate (xsub)
380111.33ms1.33msHTML::Parser::::CORE:matchHTML::Parser::CORE:match (opcode)
380211.33ms1.33msHTML::Parser::::utf8_modeHTML::Parser::utf8_mode (xsub)
19011766µs766µsHTML::Parser::::marked_sectionsHTML::Parser::marked_sections (xsub)
11160µs66µsHTML::Parser::::BEGIN@3HTML::Parser::BEGIN@3
11141µs167µ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
3290µs273µs
# spent 66µs (60+7) within HTML::Parser::BEGIN@3 which was called: # once (60µs+7µs) by Mail::SpamAssassin::HTML::BEGIN@30 at line 3
use strict;
# spent 66µs making 1 call to HTML::Parser::BEGIN@3 # spent 7µs making 1 call to strict::import
421.44ms2294µs
# spent 167µs (41+126) within HTML::Parser::BEGIN@4 which was called: # once (41µs+126µs) by Mail::SpamAssassin::HTML::BEGIN@30 at line 4
use vars qw($VERSION @ISA);
# spent 167µs making 1 call to HTML::Parser::BEGIN@4 # spent 127µs making 1 call to vars::import
5
612µs$VERSION = "3.72";
7
81458µsrequire HTML::Entities;
9
1014µsrequire XSLoader;
111488µs1471µsXSLoader::load('HTML::Parser', $VERSION);
# spent 471µs making 1 call to XSLoader::load
12
13sub new
14
# spent 70.5ms (4.18+66.3) within HTML::Parser::new which was called 190 times, avg 371µs/call: # 190 times (4.18ms+66.3ms) by Mail::SpamAssassin::HTML::new at line 93 of Mail/SpamAssassin/HTML.pm, avg 371µs/call
{
15190482µs my $class = shift;
16190770µs my $self = bless {}, $class;
171902.72ms19066.3ms return $self->init(@_);
# spent 66.3ms making 190 calls to HTML::Parser::init, avg 349µs/call
18}
19
20
21sub init
22
# spent 66.3ms (48.8+17.5) within HTML::Parser::init which was called 190 times, avg 349µs/call: # 190 times (48.8ms+17.5ms) by HTML::Parser::new at line 17, avg 349µs/call
{
23190402µs my $self = shift;
2419012.7ms1902.75ms $self->_alloc_pstate;
# spent 2.75ms making 190 calls to HTML::Parser::_alloc_pstate, avg 14µs/call
25
261901.26ms my %arg = @_;
27190731µs my $api_version = delete $arg{api_version} || (@_ ? 3 : 2);
28190472µs if ($api_version >= 4) {
29 require Carp;
30 Carp::croak("API version $api_version not supported " .
31 "by HTML::Parser $VERSION");
32 }
33
34190438µ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
571901.15ms if (my $h = delete $arg{handlers}) {
581902.01ms $h = {@$h} if ref($h) eq "ARRAY";
591908.88ms while (my($event, $cb) = each %$h) {
60133027.5ms133012.6ms $self->handler($event => @$cb);
# spent 12.6ms making 1330 calls to HTML::Parser::handler, avg 9µs/call
61 }
62 }
63
64 # In the end we try to assume plain attribute or handler
651902.83ms while (my($option, $val) = each %arg) {
661903.70ms3801.33ms if ($option =~ /^(\w+)_h$/) {
# spent 1.33ms making 380 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 {
741902.58ms190766µs $self->$option($val);
# spent 766µs making 190 calls to HTML::Parser::marked_sections, avg 4µs/call
75 }
76 }
77
781901.83ms 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 { }
11616µs*start = \&text;
11713µs*end = \&text;
11812µs*comment = \&text;
11912µs*declaration = \&text;
12012µs*process = \&text;
121
122123µs1;
123
124__END__
 
# spent 1.33ms within HTML::Parser::CORE:match which was called 380 times, avg 4µs/call: # 380 times (1.33ms+0s) by HTML::Parser::init at line 66, avg 4µs/call
sub HTML::Parser::CORE:match; # opcode
# spent 2.75ms within HTML::Parser::_alloc_pstate which was called 190 times, avg 14µs/call: # 190 times (2.75ms+0s) by HTML::Parser::init at line 24, avg 14µs/call
sub HTML::Parser::_alloc_pstate; # xsub
# spent 162ms (5.40+157) within HTML::Parser::eof which was called 190 times, avg 854µs/call: # 190 times (5.40ms+157ms) by Mail::SpamAssassin::HTML::parse at line 261 of Mail/SpamAssassin/HTML.pm, avg 854µs/call
sub HTML::Parser::eof; # xsub
# spent 12.6ms within HTML::Parser::handler which was called 1330 times, avg 9µs/call: # 1330 times (12.6ms+0s) by HTML::Parser::init at line 60, avg 9µs/call
sub HTML::Parser::handler; # xsub
# spent 766µs within HTML::Parser::marked_sections which was called 190 times, avg 4µs/call: # 190 times (766µs+0s) by HTML::Parser::init at line 74, avg 4µs/call
sub HTML::Parser::marked_sections; # xsub
# spent 20.1s (1.64+18.5) within HTML::Parser::parse which was called 190 times, avg 106ms/call: # 190 times (1.64s+18.5s) by Mail::SpamAssassin::HTML::parse at line 260 of Mail/SpamAssassin/HTML.pm, avg 106ms/call
sub HTML::Parser::parse; # xsub
# spent 1.33ms within HTML::Parser::utf8_mode which was called 380 times, avg 4µs/call: # 190 times (803µs+0s) by Mail::SpamAssassin::HTML::parse at line 255 of Mail/SpamAssassin/HTML.pm, avg 4µs/call # 190 times (528µ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