← 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__