← Index
NYTProf Performance Profile   « line view »
For /Users/timbo/perl5/perlbrew/perls/perl-5.18.2/bin/perlcritic
  Run on Sat Mar 19 22:12:22 2016
Reported on Sat Mar 19 22:14:12 2016

Filename/Users/timbo/perl5/perlbrew/perls/perl-5.18.2/lib/site_perl/5.18.2/Pod/Spell.pm
StatementsExecuted 21 statements in 1.15ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
1116.06ms839msPod::Spell::::BEGIN@10Pod::Spell::BEGIN@10
111906µs1.92msPod::Spell::::BEGIN@12Pod::Spell::BEGIN@12
111218µs295µsPod::Spell::::BEGIN@17Pod::Spell::BEGIN@17
11118µs74µsPod::Spell::::BEGIN@11Pod::Spell::BEGIN@11
11115µs15µsPod::Spell::::BEGIN@2Pod::Spell::BEGIN@2
11110µs43µsPod::Spell::::BEGIN@18Pod::Spell::BEGIN@18
1117µs11µsPod::Spell::::BEGIN@4Pod::Spell::BEGIN@4
1117µs61µsPod::Spell::::BEGIN@8Pod::Spell::BEGIN@8
1116µs18µsPod::Spell::::BEGIN@3Pod::Spell::BEGIN@3
0000s0sPod::Spell::::_is_debugPod::Spell::_is_debug
0000s0sPod::Spell::::_treat_wordsPod::Spell::_treat_words
0000s0sPod::Spell::::commandPod::Spell::command
0000s0sPod::Spell::::interior_sequencePod::Spell::interior_sequence
0000s0sPod::Spell::::newPod::Spell::new
0000s0sPod::Spell::::stopwordsPod::Spell::stopwords
0000s0sPod::Spell::::textblockPod::Spell::textblock
0000s0sPod::Spell::::verbatimPod::Spell::verbatim
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package Pod::Spell;
2237µs115µs
# spent 15µs within Pod::Spell::BEGIN@2 which was called: # once (15µs+0s) by Perl::Critic::Policy::Documentation::PodSpelling::BEGIN@21 at line 2
use 5.008;
# spent 15µs making 1 call to Pod::Spell::BEGIN@2
3222µs229µs
# spent 18µs (6+12) within Pod::Spell::BEGIN@3 which was called: # once (6µs+12µs) by Perl::Critic::Policy::Documentation::PodSpelling::BEGIN@21 at line 3
use strict;
# spent 18µs making 1 call to Pod::Spell::BEGIN@3 # spent 12µs making 1 call to strict::import
4227µs215µs
# spent 11µs (7+4) within Pod::Spell::BEGIN@4 which was called: # once (7µs+4µs) by Perl::Critic::Policy::Documentation::PodSpelling::BEGIN@21 at line 4
use warnings;
# spent 11µs making 1 call to Pod::Spell::BEGIN@4 # spent 4µs making 1 call to warnings::import
5
61700nsour $VERSION = '1.15'; # VERSION
7
8220µs2115µs
# spent 61µs (7+54) within Pod::Spell::BEGIN@8 which was called: # once (7µs+54µs) by Perl::Critic::Policy::Documentation::PodSpelling::BEGIN@21 at line 8
use base 'Pod::Parser';
# spent 61µs making 1 call to Pod::Spell::BEGIN@8 # spent 54µs making 1 call to base::import
9
102127µs1839ms
# spent 839ms (6.06+833) within Pod::Spell::BEGIN@10 which was called: # once (6.06ms+833ms) by Perl::Critic::Policy::Documentation::PodSpelling::BEGIN@21 at line 10
use Pod::Wordlist;
# spent 839ms making 1 call to Pod::Spell::BEGIN@10
11232µs2130µs
# spent 74µs (18+56) within Pod::Spell::BEGIN@11 which was called: # once (18µs+56µs) by Perl::Critic::Policy::Documentation::PodSpelling::BEGIN@21 at line 11
use Pod::Escapes ('e2char');
# spent 74µs making 1 call to Pod::Spell::BEGIN@11 # spent 56µs making 1 call to Exporter::import
122135µs21.95ms
# spent 1.92ms (906µs+1.01) within Pod::Spell::BEGIN@12 which was called: # once (906µs+1.01ms) by Perl::Critic::Policy::Documentation::PodSpelling::BEGIN@21 at line 12
use Text::Wrap ('wrap');
# spent 1.92ms making 1 call to Pod::Spell::BEGIN@12 # spent 33µs making 1 call to Exporter::import
13
14# We don't need a very new version of Text::Wrap, altho they are nicer.
151100ns$Text::Wrap::huge = 'overflow'; ## no critic ( Variables::ProhibitPackageVars )
16
17292µs2345µs
# spent 295µs (218+77) within Pod::Spell::BEGIN@17 which was called: # once (218µs+77µs) by Perl::Critic::Policy::Documentation::PodSpelling::BEGIN@21 at line 17
use locale; # so our uc/lc works right
# spent 295µs making 1 call to Pod::Spell::BEGIN@17 # spent 50µs making 1 call to locale::import
182652µs275µs
# spent 43µs (10+33) within Pod::Spell::BEGIN@18 which was called: # once (10µs+33µs) by Perl::Critic::Policy::Documentation::PodSpelling::BEGIN@21 at line 18
use Carp;
# spent 43µs making 1 call to Pod::Spell::BEGIN@18 # spent 33µs making 1 call to Exporter::import
19
20#==========================================================================
21#
22# Override some methods
23#
24
25sub new {
26 my ( $class, %args ) = @_;
27
28 my $new = $class->SUPER::new( %args );
29
30 $new->{'region'} = [];
31
32 $new->{no_wide_chars} = $args{no_wide_chars};
33
34 $new->{debug} = $args{debug} || $ENV{PERL_POD_SPELL_DEBUG};
35
36 $new->{stopwords} = $args{stopwords} || Pod::Wordlist->new(
37 _is_debug => $new->{debug}, no_wide_chars => $args{no_wide_chars}
38 );
39
40 return $new;
41}
42
43sub stopwords { my $self = shift; return $self->{stopwords} }
44
45sub verbatim { return ''; } # totally ignore verbatim sections
46
47#----------------------------------------------------------------------
48
49sub _is_debug {
50 my $self = shift;
51
52 return $self->{debug} ? 1 : 0;
53}
54
55#----------------------------------------------------------------------
56
57sub textblock {
58 my ( $self, $paragraph ) = @_;
59
60 if ( @{ $self->{'region'} } ) {
61
62 my $last_region ## no critic ( ProhibitAmbiguousNames )
63 = $self->{'region'}[-1];
64
65 if ( $last_region eq 'stopwords' ) {
66 $self->stopwords->learn_stopwords($paragraph);
67 return;
68 }
69 elsif ( $last_region eq ':stopwords' ) {
70 $self->stopwords->learn_stopwords( $self->interpolate($paragraph) );
71
72 # I guess that'd work.
73 return;
74 }
75 elsif ( $last_region !~ m/^:/s ) {
76 printf "Ignoring a textblock because inside a %s region.\n",
77 $self->{'region'}[-1] if $self->_is_debug;
78 return;
79 }
80
81 # else fall thru, as with a :footnote region or something...
82 }
83 $self->_treat_words( $self->interpolate($paragraph) );
84 return;
85}
86
87sub command { ## no critic ( ArgUnpacking)
88 # why do I have to shift these?
89 my ( $self, $command, $text ) = ( shift, shift, @_ );
90
91 return if $command eq 'pod';
92
93 if ( $command eq 'begin' )
94 { ## no critic ( ControlStructures::ProhibitCascadingIfElse )
95 my $region_name;
96
97 #print "BEGIN <$_[0]>\n";
98 if ( $text =~ m/^\s*(\S+)/s ) {
99 $region_name = $1;
100 }
101 else {
102 $region_name = 'WHATNAME';
103 }
104 print "~~~~ Beginning region \"$region_name\" ~~~~\n"
105 if $self->_is_debug;
106 push @{ $self->{'region'} }, $region_name;
107
108 }
109 elsif ( $command eq 'end' ) {
110 pop @{ $self->{'region'} }; # doesn't bother to check
111
112 }
113 elsif ( $command eq 'for' ) {
114 if ( $text =~ s/^\s*(\:?)stopwords\s*(.*)//s ) {
115 my $para = $2;
116 $para = $self->interpolate($para) if $1;
117 print "Stopword para: <$2>\n" if $self->_is_debug;
118 $self->stopwords->learn_stopwords($para);
119 }
120 }
121 elsif ( @{ $self->{'region'} } ) { # TODO: accept POD formatting
122 # ignore
123 }
124 elsif ($command eq 'head1'
125 or $command eq 'head2'
126 or $command eq 'head2'
127 or $command eq 'head3'
128 or $command eq 'item' )
129 {
130 my $out_fh = $self->output_handle();
131 print $out_fh "\n";
132 $self->_treat_words( $self->interpolate(shift) );
133
134 #print $out_fh "\n";
135 }
136 return;
137}
138
139#--------------------------------------------------------------------------
140
141sub interior_sequence { ## no critic ( Subroutines::RequireFinalReturn )
142 my ( $self, $command, $seq_arg ) = @_;
143
144 return '' if $command eq 'X' or $command eq 'Z';
145
146 # Expand escapes into the actual character now, carping if invalid.
147 if ( $command eq 'E' ) {
148 my $it = e2char( $seq_arg );
149 if ( defined $it ) {
150 return $it;
151 }
152 else {
153 carp "Unknown escape: E<$seq_arg>";
154 return "E<$seq_arg>";
155 }
156 }
157
158 # For all the other sequences, empty content produces no output.
159 return if $seq_arg eq '';
160
161 if ( $command eq 'B' or $command eq 'I' or $command eq 'S' ) {
162 $seq_arg;
163 }
164 elsif ( $command eq 'C' or $command eq 'F' ) {
165
166 # don't lose word-boundaries
167 my $out = '';
168 $out .= ' ' if s/^\s+//s;
169 my $append;
170 $append = 1 if s/\s+$//s;
171 $out .= '_' if length $seq_arg;
172
173 # which, if joined to another word, will set off the Perl-token alarm
174 $out .= ' ' if $append;
175 $out;
176 }
177 elsif ( $command eq 'L' ) {
178 return $1 if m/^([^|]+)\|/s;
179 '';
180 }
181 else {
182 carp "Unknown sequence $command<$seq_arg>";
183 }
184}
185
186#--------------------------------------------------------------------------
187
188sub _treat_words {
189 my ($self, $text) = @_;
190 my $out = $self->stopwords->strip_stopwords( $text );
191 if ( length $out ) {
192 my $out_fh = $self->output_handle();
193 print $out_fh wrap( '', '', $out ), "\n\n";
194 }
195 return;
196}
197
198#--------------------------------------------------------------------------
199
20013µs1;
201
202# ABSTRACT: a formatter for spellchecking Pod
203
204__END__