← Index
NYTProf Performance Profile   « line view »
For /usr/local/bin/sa-learn
  Run on Sun Nov 5 02:36:06 2017
Reported on Sun Nov 5 02:56:19 2017

Filename/usr/local/lib/perl5/site_perl/mach/5.24/HTML/Parser.pm
StatementsExecuted 4361 statements in 59.3ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
189111.69s21.4sHTML::Parser::::parseHTML::Parser::parse (xsub)
1891135.1ms52.6msHTML::Parser::::initHTML::Parser::init
13231112.3ms12.3msHTML::Parser::::handlerHTML::Parser::handler (xsub)
189115.58ms176msHTML::Parser::::eofHTML::Parser::eof (xsub)
189114.30ms56.9msHTML::Parser::::newHTML::Parser::new
189113.03ms3.03msHTML::Parser::::_alloc_pstateHTML::Parser::_alloc_pstate (xsub)
378111.35ms1.35msHTML::Parser::::CORE:matchHTML::Parser::CORE:match (opcode)
378211.18ms1.18msHTML::Parser::::utf8_modeHTML::Parser::utf8_mode (xsub)
18911781µs781µsHTML::Parser::::marked_sectionsHTML::Parser::marked_sections (xsub)
11151µs67µsHTML::Parser::::BEGIN@3HTML::Parser::BEGIN@3
11138µs182µ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
3285µs282µ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
use strict;
# spent 67µs making 1 call to HTML::Parser::BEGIN@3 # spent 15µs making 1 call to strict::import
421.47ms2326µ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
use vars qw($VERSION @ISA);
# spent 182µs making 1 call to HTML::Parser::BEGIN@4 # spent 144µs making 1 call to vars::import
5
612µs$VERSION = "3.72";
7
81433µsrequire HTML::Entities;
9
1014µsrequire XSLoader;
111522µs1501µsXSLoader::load('HTML::Parser', $VERSION);
# spent 501µs making 1 call to XSLoader::load
12
13sub 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
{
15189476µs my $class = shift;
16189788µs my $self = bless {}, $class;
171892.82ms18952.6ms return $self->init(@_);
# spent 52.6ms making 189 calls to HTML::Parser::init, avg 278µs/call
18}
19
20
21sub 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
{
23189407µs my $self = shift;
241894.73ms1893.03ms $self->_alloc_pstate;
# spent 3.03ms making 189 calls to HTML::Parser::_alloc_pstate, avg 16µs/call
25
261891.33ms my %arg = @_;
27189764µs my $api_version = delete $arg{api_version} || (@_ ? 3 : 2);
28189446µs if ($api_version >= 4) {
29 require Carp;
30 Carp::croak("API version $api_version not supported " .
31 "by HTML::Parser $VERSION");
32 }
33
34189439µ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.16ms if (my $h = delete $arg{handlers}) {
581891.99ms $h = {@$h} if ref($h) eq "ARRAY";
591899.22ms while (my($event, $cb) = each %$h) {
60132321.5ms132312.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
651892.72ms while (my($option, $val) = each %arg) {
661893.69ms3781.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 {
741892.44ms189781µs $self->$option($val);
# spent 781µ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;
11712µs*end = \&text;
11812µs*comment = \&text;
11912µs*declaration = \&text;
12012µs*process = \&text;
121
122118µs1;
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
sub HTML::Parser::CORE:match; # opcode
# 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
sub HTML::Parser::_alloc_pstate; # xsub
# 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
sub HTML::Parser::eof; # xsub
# 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
sub HTML::Parser::handler; # xsub
# 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
sub HTML::Parser::marked_sections; # xsub
# 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
sub HTML::Parser::parse; # xsub
# 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
sub HTML::Parser::utf8_mode; # xsub