← 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:10 2016

Filename/Users/timbo/perl5/perlbrew/perls/perl-5.18.2/lib/site_perl/5.18.2/PPI/Token/Pod.pm
StatementsExecuted 38796 statements in 91.6ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
96951161.5ms65.6msPPI::Token::Pod::::__TOKENIZER__on_line_startPPI::Token::Pod::__TOKENIZER__on_line_start
9695113.62ms3.62msPPI::Token::Pod::::CORE:matchPPI::Token::Pod::CORE:match (opcode)
11112µs24µsPPI::Token::Pod::::BEGIN@29PPI::Token::Pod::BEGIN@29
1118µs8µsPPI::Token::Pod::::BEGIN@34PPI::Token::Pod::BEGIN@34
1116µs28µsPPI::Token::Pod::::BEGIN@30PPI::Token::Pod::BEGIN@30
1116µs34µsPPI::Token::Pod::::BEGIN@33PPI::Token::Pod::BEGIN@33
5226µs6µsPPI::Token::Pod::::significantPPI::Token::Pod::significant
1113µs3µsPPI::Token::Pod::::BEGIN@31PPI::Token::Pod::BEGIN@31
0000s0sPPI::Token::Pod::::linesPPI::Token::Pod::lines
0000s0sPPI::Token::Pod::::mergePPI::Token::Pod::merge
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package PPI::Token::Pod;
2
3=pod
4
5=head1 NAME
6
7PPI::Token::Pod - Sections of POD in Perl documents
8
9=head1 INHERITANCE
10
11 PPI::Token::Pod
12 isa PPI::Token
13 isa PPI::Element
14
15=head1 DESCRIPTION
16
17A single C<PPI::Token::Pod> object represents a complete section of POD
18documentation within a Perl document.
19
20=head1 METHODS
21
22This class provides some additional methods beyond those provided by its
23L<PPI::Token> and L<PPI::Element> parent classes.
24
25Got any ideas for more methods? Submit a report to rt.cpan.org!
26
27=cut
28
29222µs236µs
# spent 24µs (12+12) within PPI::Token::Pod::BEGIN@29 which was called: # once (12µs+12µs) by PPI::Token::BEGIN@41 at line 29
use strict;
# spent 24µs making 1 call to PPI::Token::Pod::BEGIN@29 # spent 12µs making 1 call to strict::import
30225µs249µs
# spent 28µs (6+22) within PPI::Token::Pod::BEGIN@30 which was called: # once (6µs+22µs) by PPI::Token::BEGIN@41 at line 30
use Params::Util qw{_INSTANCE};
# spent 28µs making 1 call to PPI::Token::Pod::BEGIN@30 # spent 22µs making 1 call to Exporter::import
31219µs13µs
# spent 3µs within PPI::Token::Pod::BEGIN@31 which was called: # once (3µs+0s) by PPI::Token::BEGIN@41 at line 31
use PPI::Token ();
# spent 3µs making 1 call to PPI::Token::Pod::BEGIN@31
32
33228µs263µs
# spent 34µs (6+28) within PPI::Token::Pod::BEGIN@33 which was called: # once (6µs+28µs) by PPI::Token::BEGIN@41 at line 33
use vars qw{$VERSION @ISA};
# spent 34µs making 1 call to PPI::Token::Pod::BEGIN@33 # spent 28µs making 1 call to vars::import
34
# spent 8µs within PPI::Token::Pod::BEGIN@34 which was called: # once (8µs+0s) by PPI::Token::BEGIN@41 at line 37
BEGIN {
351400ns $VERSION = '1.215';
3618µs @ISA = 'PPI::Token';
371293µs18µs}
# spent 8µs making 1 call to PPI::Token::Pod::BEGIN@34
38
- -
43#####################################################################
44# PPI::Token::Pod Methods
45
46=pod
47
48=head2 merge @podtokens
49
50The C<merge> constructor takes a number of C<PPI::Token::Pod> objects,
51and returns a new object that represents one combined POD block with
52the content of all of them.
53
54Returns a new C<PPI::Token::Pod> object, or C<undef> on error.
55
56=begin testing merge after PPI::Node 4
57
58# Create the test fragments
59my $one = PPI::Token::Pod->new("=pod\n\nOne\n\n=cut\n");
60my $two = PPI::Token::Pod->new("=pod\n\nTwo");
61isa_ok( $one, 'PPI::Token::Pod' );
62isa_ok( $two, 'PPI::Token::Pod' );
63
64# Create the combined Pod
65my $merged = PPI::Token::Pod->merge($one, $two);
66isa_ok( $merged, 'PPI::Token::Pod' );
67is( $merged->content, "=pod\n\nOne\n\nTwo\n\n=cut\n", 'Merged POD looks ok' );
68
69=end testing
70
71=cut
72
73sub merge {
74 my $class = (! ref $_[0]) ? shift : return undef;
75
76 # Check there are no bad arguments
77 if ( grep { ! _INSTANCE($_, 'PPI::Token::Pod') } @_ ) {
78 return undef;
79 }
80
81 # Get the tokens, and extract the lines
82 my @content = ( map { [ $_->lines ] } @_ ) or return undef;
83
84 # Remove the leading =pod tags, trailing =cut tags, and any empty lines
85 # between them and the pod contents.
86 foreach my $pod ( @content ) {
87 # Leading =pod tag
88 if ( @$pod and $pod->[0] =~ /^=pod\b/o ) {
89 shift @$pod;
90 }
91
92 # Trailing =cut tag
93 if ( @$pod and $pod->[-1] =~ /^=cut\b/o ) {
94 pop @$pod;
95 }
96
97 # Leading and trailing empty lines
98 while ( @$pod and $pod->[0] eq '' ) { shift @$pod }
99 while ( @$pod and $pod->[-1] eq '' ) { pop @$pod }
100 }
101
102 # Remove any empty pod sections, and add the =pod and =cut tags
103 # for the merged pod back to it.
104 @content = ( [ '=pod' ], grep { @$_ } @content, [ '=cut' ] );
105
106 # Create the new object
107 $class->new( join "\n", map { join( "\n", @$_ ) . "\n" } @content );
108}
109
110=pod
111
112=head2 lines
113
114The C<lines> method takes the string of POD and breaks it into lines,
115returning them as a list.
116
117=cut
118
119sub lines {
120 split /(?:\015{1,2}\012|\015|\012)/, $_[0]->{content};
121}
122
- -
128#####################################################################
129# PPI::Element Methods
130
131### XS -> PPI/XS.xs:_PPI_Token_Pod__significant 0.900+
132514µs
# spent 6µs within PPI::Token::Pod::significant which was called 5 times, avg 1µs/call: # 3 times (3µs+0s) by PPI::Tokenizer::_previous_significant_tokens at line 699 of PPI/Tokenizer.pm, avg 1µs/call # 2 times (3µs+0s) by PPI::Lexer::_lex_structure at line 1321 of PPI/Lexer.pm, avg 1µs/call
sub significant { '' }
133
- -
138#####################################################################
139# Tokenizer Methods
140
141
# spent 65.6ms (61.5+4.04) within PPI::Token::Pod::__TOKENIZER__on_line_start which was called 9695 times, avg 7µs/call: # 9695 times (61.5ms+4.04ms) by PPI::Tokenizer::_process_next_line at line 499 of PPI/Tokenizer.pm, avg 7µs/call
sub __TOKENIZER__on_line_start {
14296951.36ms my $t = $_[1];
143
144 # Add the line to the token first
14596955.74ms $t->{token}->{content} .= $t->{line};
146
147 # Check the line to see if it is a =cut line
148969546.0ms98414.04ms if ( $t->{line} =~ /^=(\w+)/ ) {
# spent 3.62ms making 9695 calls to PPI::Token::Pod::CORE:match, avg 373ns/call # spent 415µs making 146 calls to PPI::Tokenizer::_finalize_token, avg 3µs/call
149 # End of the token
150 $t->_finalize_token if lc $1 eq 'cut';
151 }
152
153969538.1ms 0;
154}
155
15612µs1;
157
158=pod
159
160=head1 SUPPORT
161
162See the L<support section|PPI/SUPPORT> in the main module.
163
164=head1 AUTHOR
165
166Adam Kennedy E<lt>adamk@cpan.orgE<gt>
167
168=head1 COPYRIGHT
169
170Copyright 2001 - 2011 Adam Kennedy.
171
172This program is free software; you can redistribute
173it and/or modify it under the same terms as Perl itself.
174
175The full text of the license can be found in the
176LICENSE file included with this module.
177
178=cut
 
# spent 3.62ms within PPI::Token::Pod::CORE:match which was called 9695 times, avg 373ns/call: # 9695 times (3.62ms+0s) by PPI::Token::Pod::__TOKENIZER__on_line_start at line 148, avg 373ns/call
sub PPI::Token::Pod::CORE:match; # opcode