← 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/PPI/Statement/Sub.pm
StatementsExecuted 11183 statements in 54.1ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
1016117.17ms47.5msPPI::Statement::Sub::::prototypePPI::Statement::Sub::prototype
3042113.39ms3.39msPPI::Statement::Sub::::__LEXER__normalPPI::Statement::Sub::__LEXER__normal
11111µs22µsPPI::Statement::Sub::::BEGIN@33PPI::Statement::Sub::BEGIN@33
1118µs8µsPPI::Statement::Sub::::BEGIN@39PPI::Statement::Sub::BEGIN@39
1117µs32µsPPI::Statement::Sub::::BEGIN@35PPI::Statement::Sub::BEGIN@35
1116µs33µsPPI::Statement::Sub::::BEGIN@38PPI::Statement::Sub::BEGIN@38
1113µs3µsPPI::Statement::Sub::::BEGIN@34PPI::Statement::Sub::BEGIN@34
1113µs3µsPPI::Statement::Sub::::BEGIN@36PPI::Statement::Sub::BEGIN@36
0000s0sPPI::Statement::Sub::::__ANON__[:100]PPI::Statement::Sub::__ANON__[:100]
0000s0sPPI::Statement::Sub::::_completePPI::Statement::Sub::_complete
0000s0sPPI::Statement::Sub::::blockPPI::Statement::Sub::block
0000s0sPPI::Statement::Sub::::forwardPPI::Statement::Sub::forward
0000s0sPPI::Statement::Sub::::namePPI::Statement::Sub::name
0000s0sPPI::Statement::Sub::::reservedPPI::Statement::Sub::reserved
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package PPI::Statement::Sub;
2
3=pod
4
5=head1 NAME
6
7PPI::Statement::Sub - Subroutine declaration
8
9=head1 INHERITANCE
10
11 PPI::Statement::Sub
12 isa PPI::Statement
13 isa PPI::Node
14 isa PPI::Element
15
16=head1 DESCRIPTION
17
18Except for the special BEGIN, CHECK, UNITCHECK, INIT, and END subroutines
19(which are part of L<PPI::Statement::Scheduled>) all subroutine declarations
20are lexed as a PPI::Statement::Sub object.
21
22Primarily, this means all of the various C<sub foo {}> statements, but also
23forward declarations such as C<sub foo;> or C<sub foo($);>. It B<does not>
24include anonymous subroutines, as these are merely part of a normal statement.
25
26=head1 METHODS
27
28C<PPI::Statement::Sub> has a number of methods in addition to the standard
29L<PPI::Statement>, L<PPI::Node> and L<PPI::Element> methods.
30
31=cut
32
33218µs233µs
# spent 22µs (11+11) within PPI::Statement::Sub::BEGIN@33 which was called: # once (11µs+11µs) by PPI::Statement::Scheduled::BEGIN@57 at line 33
use strict;
# spent 22µs making 1 call to PPI::Statement::Sub::BEGIN@33 # spent 11µs making 1 call to strict::import
34221µs13µs
# spent 3µs within PPI::Statement::Sub::BEGIN@34 which was called: # once (3µs+0s) by PPI::Statement::Scheduled::BEGIN@57 at line 34
use List::Util ();
# spent 3µs making 1 call to PPI::Statement::Sub::BEGIN@34
35224µs258µs
# spent 32µs (7+25) within PPI::Statement::Sub::BEGIN@35 which was called: # once (7µs+25µs) by PPI::Statement::Scheduled::BEGIN@57 at line 35
use Params::Util qw{_INSTANCE};
# spent 32µs making 1 call to PPI::Statement::Sub::BEGIN@35 # spent 25µs making 1 call to Exporter::import
36218µs13µs
# spent 3µs within PPI::Statement::Sub::BEGIN@36 which was called: # once (3µs+0s) by PPI::Statement::Scheduled::BEGIN@57 at line 36
use PPI::Statement ();
# spent 3µs making 1 call to PPI::Statement::Sub::BEGIN@36
37
38227µs260µs
# spent 33µs (6+27) within PPI::Statement::Sub::BEGIN@38 which was called: # once (6µs+27µs) by PPI::Statement::Scheduled::BEGIN@57 at line 38
use vars qw{$VERSION @ISA};
# spent 33µs making 1 call to PPI::Statement::Sub::BEGIN@38 # spent 27µs making 1 call to vars::import
39
# spent 8µs within PPI::Statement::Sub::BEGIN@39 which was called: # once (8µs+0s) by PPI::Statement::Scheduled::BEGIN@57 at line 42
BEGIN {
401400ns $VERSION = '1.215';
4118µs @ISA = 'PPI::Statement';
421230µs18µs}
# spent 8µs making 1 call to PPI::Statement::Sub::BEGIN@39
43
44# Lexer clue
4530429.50ms
# spent 3.39ms within PPI::Statement::Sub::__LEXER__normal which was called 3042 times, avg 1µs/call: # 3042 times (3.39ms+0s) by PPI::Lexer::_lex_statement at line 626 of PPI/Lexer.pm, avg 1µs/call
sub __LEXER__normal { '' }
46
47sub _complete {
48 my $child = $_[0]->schild(-1);
49 return !! (
50 defined $child
51 and
52 $child->isa('PPI::Structure::Block')
53 and
54 $child->complete
55 );
56}
57
- -
62#####################################################################
63# PPI::Statement::Sub Methods
64
65=pod
66
67=head2 name
68
69The C<name> method returns the name of the subroutine being declared.
70
71In some rare cases such as a naked C<sub> at the end of the file, this may return
72false.
73
74=cut
75
76sub name {
77 my $self = shift;
78
79 # The second token should be the name, if we have one
80 my $Token = $self->schild(1) or return '';
81 $Token->isa('PPI::Token::Word') and $Token->content;
82}
83
84=pod
85
86=head2 prototype
87
88If it has one, the C<prototype> method returns the subroutine's prototype.
89It is returned in the same format as L<PPI::Token::Prototype/prototype>,
90cleaned and removed from its brackets.
91
92Returns false if the subroutine does not define a prototype
93
94=cut
95
96
# spent 47.5ms (7.17+40.4) within PPI::Statement::Sub::prototype which was called 1016 times, avg 47µs/call: # 1016 times (7.17ms+40.4ms) by Perl::Critic::Policy::Subroutines::ProhibitSubroutinePrototypes::violates at line 36 of Perl/Critic/Policy/Subroutines/ProhibitSubroutinePrototypes.pm, avg 47µs/call
sub prototype {
971016179µs my $self = shift;
98 my $Prototype = List::Util::first {
99508038.8ms1016031.7ms _INSTANCE($_, 'PPI::Token::Prototype')
# spent 27.4ms making 5080 calls to Params::Util::_INSTANCE, avg 5µs/call # spent 4.30ms making 5080 calls to UNIVERSAL::isa, avg 846ns/call
10010162.95ms203240.4ms } $self->children;
# spent 38.4ms making 1016 calls to List::Util::first, avg 38µs/call # spent 1.92ms making 1016 calls to PPI::Node::children, avg 2µs/call
10110162.28ms defined($Prototype) ? $Prototype->prototype : '';
102}
103
104=pod
105
106=head2 block
107
108With its name and implementation shared with L<PPI::Statement::Scheduled>,
109the C<block> method finds and returns the actual Structure object of the
110code block for this subroutine.
111
112Returns false if this is a forward declaration, or otherwise does not have a
113code block.
114
115=cut
116
117sub block {
118 my $self = shift;
119 my $lastchild = $self->schild(-1) or return '';
120 $lastchild->isa('PPI::Structure::Block') and $lastchild;
121}
122
123=pod
124
125=head2 forward
126
127The C<forward> method returns true if the subroutine declaration is a
128forward declaration.
129
130That is, it returns false if the subroutine has a code block, or true
131if it does not.
132
133=cut
134
135sub forward {
136 ! shift->block;
137}
138
139=pod
140
141=head2 reserved
142
143The C<reserved> method provides a convenience method for checking to see
144if this is a special reserved subroutine. It does not check against any
145particular list of reserved sub names, but just returns true if the name
146is all uppercase, as defined in L<perlsub>.
147
148Note that in the case of BEGIN, CHECK, UNITCHECK, INIT and END, these will be
149defined as L<PPI::Statement::Scheduled> objects, not subroutines.
150
151Returns true if it is a special reserved subroutine, or false if not.
152
153=cut
154
155sub reserved {
156 my $self = shift;
157 my $name = $self->name or return '';
158 $name eq uc $name;
159}
160
16112µs1;
162
163=pod
164
165=head1 TO DO
166
167- Write unit tests for this package
168
169=head1 SUPPORT
170
171See the L<support section|PPI/SUPPORT> in the main module.
172
173=head1 AUTHOR
174
175Adam Kennedy E<lt>adamk@cpan.orgE<gt>
176
177=head1 COPYRIGHT
178
179Copyright 2001 - 2011 Adam Kennedy.
180
181This program is free software; you can redistribute
182it and/or modify it under the same terms as Perl itself.
183
184The full text of the license can be found in the
185LICENSE file included with this module.
186
187=cut