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

Filename/Users/timbo/perl5/perlbrew/perls/perl-5.18.2/lib/site_perl/5.18.2/PPIx/Utilities/Statement.pm
StatementsExecuted 17 statements in 554µs
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
111470µs26.6msPPIx::Utilities::Statement::::BEGIN@19PPIx::Utilities::Statement::BEGIN@19
11117µs17µsPPIx::Utilities::Statement::::BEGIN@10PPIx::Utilities::Statement::BEGIN@10
11110µs73µsPPIx::Utilities::Statement::::BEGIN@21PPIx::Utilities::Statement::BEGIN@21
1117µs26µsPPIx::Utilities::Statement::::BEGIN@16PPIx::Utilities::Statement::BEGIN@16
1117µs10µsPPIx::Utilities::Statement::::BEGIN@12PPIx::Utilities::Statement::BEGIN@12
1116µs18µsPPIx::Utilities::Statement::::BEGIN@11PPIx::Utilities::Statement::BEGIN@11
0000s0sPPIx::Utilities::Statement::::_get_constant_names_from_constant_pragmaPPIx::Utilities::Statement::_get_constant_names_from_constant_pragma
0000s0sPPIx::Utilities::Statement::::get_constant_name_elements_from_declaring_statementPPIx::Utilities::Statement::get_constant_name_elements_from_declaring_statement
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1##############################################################################
2# $URL: http://perlcritic.tigris.org/svn/perlcritic/trunk/distributions/PPIx-Utilities/lib/PPIx/Utilities/Statement.pm $
3# $Date: 2010-11-13 14:25:12 -0600 (Sat, 13 Nov 2010) $
4# $Author: clonezone $
5# $Revision: 3990 $
6##############################################################################
7
8package PPIx::Utilities::Statement;
9
10240µs117µs
# spent 17µs within PPIx::Utilities::Statement::BEGIN@10 which was called: # once (17µs+0s) by Perl::Critic::Policy::NamingConventions::Capitalization::BEGIN@29 at line 10
use 5.006001;
# spent 17µs making 1 call to PPIx::Utilities::Statement::BEGIN@10
11218µs229µs
# spent 18µs (6+11) within PPIx::Utilities::Statement::BEGIN@11 which was called: # once (6µs+11µs) by Perl::Critic::Policy::NamingConventions::Capitalization::BEGIN@29 at line 11
use strict;
# spent 18µs making 1 call to PPIx::Utilities::Statement::BEGIN@11 # spent 11µs making 1 call to strict::import
12226µs214µs
# spent 10µs (7+4) within PPIx::Utilities::Statement::BEGIN@12 which was called: # once (7µs+4µs) by Perl::Critic::Policy::NamingConventions::Capitalization::BEGIN@29 at line 12
use warnings;
# spent 10µs making 1 call to PPIx::Utilities::Statement::BEGIN@12 # spent 4µs making 1 call to warnings::import
13
141700nsour $VERSION = '1.001000';
15
16232µs245µs
# spent 26µs (7+19) within PPIx::Utilities::Statement::BEGIN@16 which was called: # once (7µs+19µs) by Perl::Critic::Policy::NamingConventions::Capitalization::BEGIN@29 at line 16
use Readonly;
# spent 26µs making 1 call to PPIx::Utilities::Statement::BEGIN@16 # spent 19µs making 1 call to Exporter::import
17
18
193124µs226.6ms
# spent 26.6ms (470µs+26.1) within PPIx::Utilities::Statement::BEGIN@19 which was called: # once (470µs+26.1ms) by Perl::Critic::Policy::NamingConventions::Capitalization::BEGIN@29 at line 19
use PPI 1.208 qw< >; # Just for the version check.
# spent 26.6ms making 1 call to PPIx::Utilities::Statement::BEGIN@19 # spent 12µs making 1 call to UNIVERSAL::VERSION
20
212305µs2136µs
# spent 73µs (10+63) within PPIx::Utilities::Statement::BEGIN@21 which was called: # once (10µs+63µs) by Perl::Critic::Policy::NamingConventions::Capitalization::BEGIN@29 at line 21
use base 'Exporter';
# spent 73µs making 1 call to PPIx::Utilities::Statement::BEGIN@21 # spent 63µs making 1 call to base::import
22
231800nsour @EXPORT_OK = qw(
24 get_constant_name_elements_from_declaring_statement
25);
26
27
2813µs143µsReadonly::Hash my %IS_COMMA => ( q[,] => 1, q[=>] => 1 );
# spent 43µs making 1 call to Readonly::Hash
29
30
31sub get_constant_name_elements_from_declaring_statement {
32 my ($element) = @_;
33
34 return if not $element;
35 return if not $element->isa('PPI::Statement');
36
37 if ( $element->isa('PPI::Statement::Include') ) {
38 my $pragma;
39 if ( $pragma = $element->pragma() and $pragma eq 'constant' ) {
40 return _get_constant_names_from_constant_pragma($element);
41 } # end if
42 } elsif ( not $element->specialized() and $element->schildren() > 2 ) {
43 my $supposed_constant_function = $element->schild(0)->content();
44 my $declaring_scope = $element->schild(1)->content();
45
46 if (
47 (
48 $supposed_constant_function eq 'const'
49 or $supposed_constant_function =~ m< \A Readonly \b >xms
50 )
51 and ($declaring_scope eq 'our' or $declaring_scope eq 'my')
52 ) {
53 return $element->schild(2);
54 } # end if
55 } # end if
56
57 return;
58} # end get_constant_name_elements_from_declaring_statement()
59
60
61sub _get_constant_names_from_constant_pragma {
62 my ($include) = @_;
63
64 my @arguments = $include->arguments() or return;
65
66 my $follower = $arguments[0];
67 return if not defined $follower;
68
69 # We test for a 'PPI::Structure::Block' in the following because some
70 # versions of PPI parse the last element of 'use constant { ONE => 1, TWO
71 # => 2 }' as a block rather than a constructor. As of PPI 1.206, PPI
72 # handles the above correctly, but still blows it on 'use constant 1.16 {
73 # ONE => 1, TWO => 2 }'.
74 if (
75 $follower->isa( 'PPI::Structure::Constructor' )
76 or $follower->isa( 'PPI::Structure::Block' )
77 ) {
78 my $statement = $follower->schild( 0 ) or return;
79 $statement->isa( 'PPI::Statement' ) or return;
80
81 my @elements;
82 my $inx = 0;
83 foreach my $child ( $statement->schildren() ) {
84 if (not $inx % 2) {
85 push @{ $elements[ $inx ] ||= [] }, $child;
86 } # end if
87
88 if ( $IS_COMMA{ $child->content() } ) {
89 $inx++;
90 } # end if
91 } # end foreach
92
93 return map
94 {
95 (
96 $_
97 and @{$_} == 2
98 and '=>' eq $_->[1]->content()
99 and $_->[0]->isa( 'PPI::Token::Word' )
100 )
101 ? $_->[0]
102 : ()
103 }
104 @elements;
105 } else {
106 return $follower;
107 } # end if
108
109 return $follower;
110} # end _get_constant_names_from_constant_pragma()
111
112
11314µs1;
114
115__END__