← 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/Perl/Critic/Policy/TestingAndDebugging/RequireUseStrict.pm
StatementsExecuted 96840 statements in 241ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
1441178.2ms431msPerl::Critic::Policy::TestingAndDebugging::RequireUseStrict::::violatesPerl::Critic::Policy::TestingAndDebugging::RequireUseStrict::violates
105381167.7ms85.8msPerl::Critic::Policy::TestingAndDebugging::RequireUseStrict::::_statement_isnt_include_or_packagePerl::Critic::Policy::TestingAndDebugging::RequireUseStrict::_statement_isnt_include_or_package
1441139.0ms128msPerl::Critic::Policy::TestingAndDebugging::RequireUseStrict::::_find_isnt_include_or_packagePerl::Critic::Policy::TestingAndDebugging::RequireUseStrict::_find_isnt_include_or_package
20111118.1ms51.9msPerl::Critic::Policy::TestingAndDebugging::RequireUseStrict::::__ANON__[:116]Perl::Critic::Policy::TestingAndDebugging::RequireUseStrict::__ANON__[:116]
14411902┬Ás902┬ÁsPerl::Critic::Policy::TestingAndDebugging::RequireUseStrict::::_generate_is_use_strictPerl::Critic::Policy::TestingAndDebugging::RequireUseStrict::_generate_is_use_strict
14411279┬Ás279┬ÁsPerl::Critic::Policy::TestingAndDebugging::RequireUseStrict::::default_maximum_violations_per_documentPerl::Critic::Policy::TestingAndDebugging::RequireUseStrict::default_maximum_violations_per_document
14411267┬Ás267┬ÁsPerl::Critic::Policy::TestingAndDebugging::RequireUseStrict::::applies_toPerl::Critic::Policy::TestingAndDebugging::RequireUseStrict::applies_to
11116┬Ás16┬ÁsPerl::Critic::Policy::TestingAndDebugging::RequireUseStrict::::BEGIN@10Perl::Critic::Policy::TestingAndDebugging::RequireUseStrict::BEGIN@10
11115┬Ás40┬ÁsPerl::Critic::Policy::TestingAndDebugging::RequireUseStrict::::BEGIN@14Perl::Critic::Policy::TestingAndDebugging::RequireUseStrict::BEGIN@14
11114┬Ás16┬ÁsPerl::Critic::Policy::TestingAndDebugging::RequireUseStrict::::supported_parametersPerl::Critic::Policy::TestingAndDebugging::RequireUseStrict::supported_parameters
1118┬Ás29┬ÁsPerl::Critic::Policy::TestingAndDebugging::RequireUseStrict::::BEGIN@16Perl::Critic::Policy::TestingAndDebugging::RequireUseStrict::BEGIN@16
1118┬Ás28┬ÁsPerl::Critic::Policy::TestingAndDebugging::RequireUseStrict::::BEGIN@15Perl::Critic::Policy::TestingAndDebugging::RequireUseStrict::BEGIN@15
1117┬Ás11┬ÁsPerl::Critic::Policy::TestingAndDebugging::RequireUseStrict::::BEGIN@12Perl::Critic::Policy::TestingAndDebugging::RequireUseStrict::BEGIN@12
1117┬Ás18┬ÁsPerl::Critic::Policy::TestingAndDebugging::RequireUseStrict::::BEGIN@11Perl::Critic::Policy::TestingAndDebugging::RequireUseStrict::BEGIN@11
1117┬Ás56┬ÁsPerl::Critic::Policy::TestingAndDebugging::RequireUseStrict::::BEGIN@19Perl::Critic::Policy::TestingAndDebugging::RequireUseStrict::BEGIN@19
1117┬Ás169┬ÁsPerl::Critic::Policy::TestingAndDebugging::RequireUseStrict::::BEGIN@18Perl::Critic::Policy::TestingAndDebugging::RequireUseStrict::BEGIN@18
1116┬Ás7┬ÁsPerl::Critic::Policy::TestingAndDebugging::RequireUseStrict::::default_severityPerl::Critic::Policy::TestingAndDebugging::RequireUseStrict::default_severity
0000s0sPerl::Critic::Policy::TestingAndDebugging::RequireUseStrict::::default_themesPerl::Critic::Policy::TestingAndDebugging::RequireUseStrict::default_themes
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$
3# $Date$
4# $Author$
5# $Revision$
6##############################################################################
7
8package Perl::Critic::Policy::TestingAndDebugging::RequireUseStrict;
9
10243┬Ás116┬Ás
# spent 16┬Ás within Perl::Critic::Policy::TestingAndDebugging::RequireUseStrict::BEGIN@10 which was called: # once (16┬Ás+0s) by Module::Pluggable::Object::_require at line 10
use 5.006001;
11220┬Ás229┬Ás
# spent 18┬Ás (7+11) within Perl::Critic::Policy::TestingAndDebugging::RequireUseStrict::BEGIN@11 which was called: # once (7┬Ás+11┬Ás) by Module::Pluggable::Object::_require at line 11
use strict;
# spent 18┬Ás making 1 call to Perl::Critic::Policy::TestingAndDebugging::RequireUseStrict::BEGIN@11 # spent 11┬Ás making 1 call to strict::import
12222┬Ás215┬Ás
# spent 11┬Ás (7+4) within Perl::Critic::Policy::TestingAndDebugging::RequireUseStrict::BEGIN@12 which was called: # once (7┬Ás+4┬Ás) by Module::Pluggable::Object::_require at line 12
use warnings;
# spent 11┬Ás making 1 call to Perl::Critic::Policy::TestingAndDebugging::RequireUseStrict::BEGIN@12 # spent 4┬Ás making 1 call to warnings::import
13
14337┬Ás366┬Ás
# spent 40┬Ás (15+26) within Perl::Critic::Policy::TestingAndDebugging::RequireUseStrict::BEGIN@14 which was called: # once (15┬Ás+26┬Ás) by Module::Pluggable::Object::_require at line 14
use version 0.77;
# spent 40┬Ás making 1 call to Perl::Critic::Policy::TestingAndDebugging::RequireUseStrict::BEGIN@14 # spent 17┬Ás making 1 call to version::import # spent 8┬Ás making 1 call to UNIVERSAL::VERSION
15222┬Ás248┬Ás
# spent 28┬Ás (8+20) within Perl::Critic::Policy::TestingAndDebugging::RequireUseStrict::BEGIN@15 which was called: # once (8┬Ás+20┬Ás) by Module::Pluggable::Object::_require at line 15
use Readonly;
# spent 28┬Ás making 1 call to Perl::Critic::Policy::TestingAndDebugging::RequireUseStrict::BEGIN@15 # spent 20┬Ás making 1 call to Exporter::import
16222┬Ás250┬Ás
# spent 29┬Ás (8+21) within Perl::Critic::Policy::TestingAndDebugging::RequireUseStrict::BEGIN@16 which was called: # once (8┬Ás+21┬Ás) by Module::Pluggable::Object::_require at line 16
use Scalar::Util qw{ blessed };
# spent 29┬Ás making 1 call to Perl::Critic::Policy::TestingAndDebugging::RequireUseStrict::BEGIN@16 # spent 21┬Ás making 1 call to Exporter::import
17
18223┬Ás2331┬Ás
# spent 169┬Ás (7+162) within Perl::Critic::Policy::TestingAndDebugging::RequireUseStrict::BEGIN@18 which was called: # once (7┬Ás+162┬Ás) by Module::Pluggable::Object::_require at line 18
use Perl::Critic::Utils qw{ :severities $EMPTY };
# spent 169┬Ás making 1 call to Perl::Critic::Policy::TestingAndDebugging::RequireUseStrict::BEGIN@18 # spent 162┬Ás making 1 call to Exporter::import
192460┬Ás2106┬Ás
# spent 56┬Ás (7+49) within Perl::Critic::Policy::TestingAndDebugging::RequireUseStrict::BEGIN@19 which was called: # once (7┬Ás+49┬Ás) by Module::Pluggable::Object::_require at line 19
use base 'Perl::Critic::Policy';
# spent 56┬Ás making 1 call to Perl::Critic::Policy::TestingAndDebugging::RequireUseStrict::BEGIN@19 # spent 49┬Ás making 1 call to base::import
20
211500nsour $VERSION = '1.121';
22
23#-----------------------------------------------------------------------------
24
2512┬Ás128┬ÁsReadonly::Scalar my $DESC => q{Code before strictures are enabled};
# spent 28┬Ás making 1 call to Readonly::Scalar
2612┬Ás142┬ÁsReadonly::Scalar my $EXPL => [ 429 ];
# spent 42┬Ás making 1 call to Readonly::Scalar
27
2812┬Ás232┬ÁsReadonly::Scalar my $PERL_VERSION_WHICH_IMPLIES_STRICTURE => qv('v5.11.0');
# spent 21┬Ás making 1 call to Readonly::Scalar # spent 11┬Ás making 1 call to version::__ANON__[version.pm:151]
29
30#-----------------------------------------------------------------------------
31
32
# spent 16┬Ás (14+2) within Perl::Critic::Policy::TestingAndDebugging::RequireUseStrict::supported_parameters which was called: # once (14┬Ás+2┬Ás) by Perl::Critic::Policy::new at line 88 of Perl/Critic/Policy.pm
sub supported_parameters {
33 return (
34 {
35111┬Ás22┬Ás name => 'equivalent_modules',
# spent 2┬Ás making 2 calls to Readonly::Scalar::FETCH, avg 1┬Ás/call
36 description =>
37 q<The additional modules to treat as equivalent to "strict".>,
38 default_string => $EMPTY,
39 behavior => 'string list',
40 list_always_present_values =>
41 [ qw< strict Moose Moose::Role Moose::Util::TypeConstraints > ],
42 },
43 );
44}
45
4612┬Ás
# spent 7┬Ás (6+1) within Perl::Critic::Policy::TestingAndDebugging::RequireUseStrict::default_severity which was called: # once (6┬Ás+1┬Ás) by Perl::Critic::Policy::get_severity at line 331 of Perl/Critic/Policy.pm
sub default_severity { return $SEVERITY_HIGHEST }
47sub default_themes { return qw( core pbp bugs certrule certrec ) }
481441.97ms
# spent 267┬Ás within Perl::Critic::Policy::TestingAndDebugging::RequireUseStrict::applies_to which was called 144 times, avg 2┬Ás/call: # 144 times (267┬Ás+0s) by Perl::Critic::_critique at line 165 of Perl/Critic.pm, avg 2┬Ás/call
sub applies_to { return 'PPI::Document' }
49
501442.08ms
# spent 279┬Ás within Perl::Critic::Policy::TestingAndDebugging::RequireUseStrict::default_maximum_violations_per_document which was called 144 times, avg 2┬Ás/call: # 144 times (279┬Ás+0s) by Perl::Critic::Policy::get_maximum_violations_per_document at line 308 of Perl/Critic/Policy.pm, avg 2┬Ás/call
sub default_maximum_violations_per_document { return 1; }
51
52#-----------------------------------------------------------------------------
53
54
# spent 431ms (78.2+353) within Perl::Critic::Policy::TestingAndDebugging::RequireUseStrict::violates which was called 144 times, avg 3.00ms/call: # 144 times (78.2ms+353ms) by Perl::Critic::_critique at line 183 of Perl/Critic.pm, avg 3.00ms/call
sub violates {
55144104┬Ás my ( $self, undef, $doc ) = @_;
56
57 # Find the first 'use strict' statement
581441.31ms28881.2ms my $strict_stmnt = $doc->find_first( $self->_generate_is_use_strict() );
# spent 80.3ms making 144 calls to Perl::Critic::Document::find_first, avg 558┬Ás/call # spent 902┬Ás making 144 calls to Perl::Critic::Policy::TestingAndDebugging::RequireUseStrict::_generate_is_use_strict, avg 6┬Ás/call
59144832┬Ás2882.54ms my $strict_line = $strict_stmnt ? $strict_stmnt->location()->[0] : undef;
# spent 2.44ms making 144 calls to PPI::Node::location, avg 17┬Ás/call # spent 104┬Ás making 144 calls to PPI::Util::TRUE, avg 725ns/call
60
61 # Find all statements that aren't 'use', 'require', or 'package'
62144352┬Ás144128ms my $stmnts_ref = $self->_find_isnt_include_or_package($doc);
6314434┬Ás return if not $stmnts_ref;
64
65 # If the 'use strict' statement is not defined, or the other
66 # statement appears before the 'use strict', then it violates.
67
6814474┬Ás my @viols = ();
69144138┬Ás for my $stmnt ( @{ $stmnts_ref } ) {
70941236.8ms941210.9ms last if $stmnt->isa('PPI::Statement::End');
# spent 10.9ms making 9412 calls to UNIVERSAL::isa, avg 1┬Ás/call
71926828.1ms92688.83ms last if $stmnt->isa('PPI::Statement::Data');
# spent 8.83ms making 9268 calls to UNIVERSAL::isa, avg 953ns/call
72
73926811.8ms9268121ms my $stmnt_line = $stmnt->location()->[0];
# spent 121ms making 9268 calls to PPI::Node::location, avg 13┬Ás/call
7492683.86ms if ( (! defined $strict_line) || ($stmnt_line < $strict_line) ) {
75 push @viols, $self->violation( $DESC, $EXPL, $stmnt );
76 }
77 }
78144706┬Ás return @viols;
79}
80
81#-----------------------------------------------------------------------------
82
83
# spent 902┬Ás within Perl::Critic::Policy::TestingAndDebugging::RequireUseStrict::_generate_is_use_strict which was called 144 times, avg 6┬Ás/call: # 144 times (902┬Ás+0s) by Perl::Critic::Policy::TestingAndDebugging::RequireUseStrict::violates at line 58, avg 6┬Ás/call
sub _generate_is_use_strict {
8414451┬Ás my ($self) = @_;
85
86
# spent 51.9ms (18.1+33.8) within Perl::Critic::Policy::TestingAndDebugging::RequireUseStrict::__ANON__[/Users/timbo/perl5/perlbrew/perls/perl-5.18.2/lib/site_perl/5.18.2/Perl/Critic/Policy/TestingAndDebugging/RequireUseStrict.pm:116] which was called 2011 times, avg 26┬Ás/call: # 2011 times (18.1ms+33.8ms) by PPI::Node::find_first at line 438 of PPI/Node.pm, avg 26┬Ás/call
return sub {
872011562┬Ás my (undef, $elem) = @_;
88
89201120.8ms20112.01ms return 0 if !$elem->isa('PPI::Statement::Include');
# spent 2.01ms making 2011 calls to UNIVERSAL::isa, avg 998ns/call
90286364┬Ás2865.09ms return 0 if $elem->type() ne 'use';
# spent 5.09ms making 286 calls to PPI::Statement::Include::type, avg 18┬Ás/call
91
92 # We only want file-scoped pragmas
93286409┬Ás2861.21ms my $parent = $elem->parent();
# spent 1.21ms making 286 calls to PPI::Element::parent, avg 4┬Ás/call
942861.02ms286324┬Ás return 0 if !$parent->isa('PPI::Document');
# spent 324┬Ás making 286 calls to UNIVERSAL::isa, avg 1┬Ás/call
95
962861.73ms57022.6ms if ( my $pragma = $elem->pragma() ) {
# spent 10.7ms making 286 calls to PPI::Statement::Include::pragma, avg 37┬Ás/call # spent 6.43ms making 142 calls to PPI::Statement::Include::version, avg 45┬Ás/call # spent 5.44ms making 142 calls to PPI::Statement::Include::module, avg 38┬Ás/call
97 return 1 if $self->{_equivalent_modules}{$pragma};
98 }
99 elsif ( my $module = $elem->module() ) {
100 return 1 if $self->{_equivalent_modules}{$module};
101 }
102 elsif ( my $version = $elem->version() ) {
103 # Currently Adam returns a string here. He has said he may return
104 # a version object in the future, so best be prepared.
105142659┬Ás142162┬Ás if ( not blessed( $version ) or not $version->isa( 'version' ) ) {
# spent 162┬Ás making 142 calls to Scalar::Util::blessed, avg 1┬Ás/call
106142395┬Ás if ( 'v' ne substr $version, 0, 1
107 and ( $version =~ tr/././ ) > 1 ) {
108 $version = 'v' . $version;
109 }
1101421.52ms142732┬Ás $version = version->parse( $version );
# spent 732┬Ás making 142 calls to version::parse, avg 5┬Ás/call
111 }
1121424.88ms5681.97ms return 1 if $PERL_VERSION_WHICH_IMPLIES_STRICTURE <= $version;
# spent 1.46ms making 142 calls to version::(<=>, avg 10┬Ás/call # spent 502┬Ás making 426 calls to Readonly::Scalar::FETCH, avg 1┬Ás/call
113 }
114
115142611┬Ás return 0;
1161441.01ms };
117}
118
119#-----------------------------------------------------------------------------
120# Here, we're using the fact that Perl::Critic::Document::find() is optimized
121# to search for elements based on their type. This is faster than using the
122# native PPI::Node::find() method with a custom callback function.
123
124
# spent 128ms (39.0+89.5) within Perl::Critic::Policy::TestingAndDebugging::RequireUseStrict::_find_isnt_include_or_package which was called 144 times, avg 892┬Ás/call: # 144 times (39.0ms+89.5ms) by Perl::Critic::Policy::TestingAndDebugging::RequireUseStrict::violates at line 62, avg 892┬Ás/call
sub _find_isnt_include_or_package {
12514473┬Ás my ($self, $doc) = @_;
126144242┬Ás1443.63ms my $all_statements = $doc->find('PPI::Statement') or return;
# spent 3.63ms making 144 calls to Perl::Critic::Document::find, avg 25┬Ás/call
1271068210.9ms1053885.8ms my @wanted_statements = grep { _statement_isnt_include_or_package($_) } @{$all_statements};
128144474┬Ás return @wanted_statements ? \@wanted_statements : ();
129}
130
131#-----------------------------------------------------------------------------
132
133
# spent 85.8ms (67.7+18.1) within Perl::Critic::Policy::TestingAndDebugging::RequireUseStrict::_statement_isnt_include_or_package which was called 10538 times, avg 8┬Ás/call: # 10538 times (67.7ms+18.1ms) by Perl::Critic::Policy::TestingAndDebugging::RequireUseStrict::_find_isnt_include_or_package at line 127, avg 8┬Ás/call
sub _statement_isnt_include_or_package {
134105381.79ms my ($elem) = @_;
1351053835.7ms105389.42ms return 0 if $elem->isa('PPI::Statement::Package');
# spent 9.42ms making 10538 calls to UNIVERSAL::isa, avg 894ns/call
1361039439.8ms103948.71ms return 0 if $elem->isa('PPI::Statement::Include');
# spent 8.71ms making 10394 calls to UNIVERSAL::isa, avg 838ns/call
137941229.5ms return 1;
138}
139
14014┬Ás1;
141
142__END__