← 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/Perl/Critic/Policy/Modules/RequireFilenameMatchesPackage.pm
StatementsExecuted 6212 statements in 10.6ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
1441110.7ms27.1msPerl::Critic::Policy::Modules::RequireFilenameMatchesPackage::::violatesPerl::Critic::Policy::Modules::RequireFilenameMatchesPackage::violates
14411774µs1.12msPerl::Critic::Policy::Modules::RequireFilenameMatchesPackage::::prepare_to_scan_documentPerl::Critic::Policy::Modules::RequireFilenameMatchesPackage::prepare_to_scan_document
14411372µs372µsPerl::Critic::Policy::Modules::RequireFilenameMatchesPackage::::CORE:substPerl::Critic::Policy::Modules::RequireFilenameMatchesPackage::CORE:subst (opcode)
14411262µs262µsPerl::Critic::Policy::Modules::RequireFilenameMatchesPackage::::applies_toPerl::Critic::Policy::Modules::RequireFilenameMatchesPackage::applies_to
11116µs16µsPerl::Critic::Policy::Modules::RequireFilenameMatchesPackage::::BEGIN@10Perl::Critic::Policy::Modules::RequireFilenameMatchesPackage::BEGIN@10
1118µs57µsPerl::Critic::Policy::Modules::RequireFilenameMatchesPackage::::BEGIN@19Perl::Critic::Policy::Modules::RequireFilenameMatchesPackage::BEGIN@19
1118µs28µsPerl::Critic::Policy::Modules::RequireFilenameMatchesPackage::::BEGIN@13Perl::Critic::Policy::Modules::RequireFilenameMatchesPackage::BEGIN@13
1118µs11µsPerl::Critic::Policy::Modules::RequireFilenameMatchesPackage::::BEGIN@12Perl::Critic::Policy::Modules::RequireFilenameMatchesPackage::BEGIN@12
1117µs18µsPerl::Critic::Policy::Modules::RequireFilenameMatchesPackage::::BEGIN@11Perl::Critic::Policy::Modules::RequireFilenameMatchesPackage::BEGIN@11
1117µs332µsPerl::Critic::Policy::Modules::RequireFilenameMatchesPackage::::BEGIN@17Perl::Critic::Policy::Modules::RequireFilenameMatchesPackage::BEGIN@17
1116µs7µsPerl::Critic::Policy::Modules::RequireFilenameMatchesPackage::::default_severityPerl::Critic::Policy::Modules::RequireFilenameMatchesPackage::default_severity
1115µs5µsPerl::Critic::Policy::Modules::RequireFilenameMatchesPackage::::BEGIN@15Perl::Critic::Policy::Modules::RequireFilenameMatchesPackage::BEGIN@15
1112µs2µsPerl::Critic::Policy::Modules::RequireFilenameMatchesPackage::::supported_parametersPerl::Critic::Policy::Modules::RequireFilenameMatchesPackage::supported_parameters
0000s0sPerl::Critic::Policy::Modules::RequireFilenameMatchesPackage::::default_themesPerl::Critic::Policy::Modules::RequireFilenameMatchesPackage::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::Modules::RequireFilenameMatchesPackage;
9
10239µs116µs
# spent 16µs within Perl::Critic::Policy::Modules::RequireFilenameMatchesPackage::BEGIN@10 which was called: # once (16µs+0s) by Module::Pluggable::Object::_require at line 10
use 5.006001;
11224µs229µs
# spent 18µs (7+11) within Perl::Critic::Policy::Modules::RequireFilenameMatchesPackage::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::Modules::RequireFilenameMatchesPackage::BEGIN@11 # spent 11µs making 1 call to strict::import
12222µs215µs
# spent 11µs (8+4) within Perl::Critic::Policy::Modules::RequireFilenameMatchesPackage::BEGIN@12 which was called: # once (8µs+4µs) by Module::Pluggable::Object::_require at line 12
use warnings;
# spent 11µs making 1 call to Perl::Critic::Policy::Modules::RequireFilenameMatchesPackage::BEGIN@12 # spent 4µs making 1 call to warnings::import
13220µs248µs
# spent 28µs (8+20) within Perl::Critic::Policy::Modules::RequireFilenameMatchesPackage::BEGIN@13 which was called: # once (8µs+20µs) by Module::Pluggable::Object::_require at line 13
use Readonly;
# spent 28µs making 1 call to Perl::Critic::Policy::Modules::RequireFilenameMatchesPackage::BEGIN@13 # spent 20µs making 1 call to Exporter::import
14
15222µs15µs
# spent 5µs within Perl::Critic::Policy::Modules::RequireFilenameMatchesPackage::BEGIN@15 which was called: # once (5µs+0s) by Module::Pluggable::Object::_require at line 15
use File::Spec;
16
17225µs2658µs
# spent 332µs (7+325) within Perl::Critic::Policy::Modules::RequireFilenameMatchesPackage::BEGIN@17 which was called: # once (7µs+325µs) by Module::Pluggable::Object::_require at line 17
use Perl::Critic::Utils qw{ :characters :severities };
# spent 332µs making 1 call to Perl::Critic::Policy::Modules::RequireFilenameMatchesPackage::BEGIN@17 # spent 325µs making 1 call to Exporter::import
18
192314µs2106µs
# spent 57µs (8+49) within Perl::Critic::Policy::Modules::RequireFilenameMatchesPackage::BEGIN@19 which was called: # once (8µs+49µs) by Module::Pluggable::Object::_require at line 19
use base 'Perl::Critic::Policy';
# spent 57µs making 1 call to Perl::Critic::Policy::Modules::RequireFilenameMatchesPackage::BEGIN@19 # spent 49µs making 1 call to base::import
20
211600nsour $VERSION = '1.121';
22
23#-----------------------------------------------------------------------------
24
2512µs129µsReadonly::Scalar my $DESC => q{Package declaration must match filename};
# spent 29µs making 1 call to Readonly::Scalar
2611µs120µsReadonly::Scalar my $EXPL => q{Correct the filename or package statement};
# spent 20µs making 1 call to Readonly::Scalar
27
28#-----------------------------------------------------------------------------
29
3015µs
# spent 2µs within Perl::Critic::Policy::Modules::RequireFilenameMatchesPackage::supported_parameters which was called: # once (2µs+0s) by Perl::Critic::Policy::new at line 88 of Perl/Critic/Policy.pm
sub supported_parameters { return () }
3112µs
# spent 7µs (6+1) within Perl::Critic::Policy::Modules::RequireFilenameMatchesPackage::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 }
32sub default_themes { return qw(core bugs) }
33144426µs
# spent 262µs within Perl::Critic::Policy::Modules::RequireFilenameMatchesPackage::applies_to which was called 144 times, avg 2µs/call: # 144 times (262µs+0s) by Perl::Critic::_critique at line 165 of Perl/Critic.pm, avg 2µs/call
sub applies_to { return 'PPI::Document' }
34
35#-----------------------------------------------------------------------------
36
37
# spent 1.12ms (774µs+345µs) within Perl::Critic::Policy::Modules::RequireFilenameMatchesPackage::prepare_to_scan_document which was called 144 times, avg 8µs/call: # 144 times (774µs+345µs) by Perl::Critic::_critique at line 157 of Perl/Critic.pm, avg 8µs/call
sub prepare_to_scan_document {
3814457µs my ( $self, $document ) = @_;
39144604µs144345µs return $document->is_module(); # Must be a library or module.
# spent 345µs making 144 calls to Perl::Critic::Document::is_module, avg 2µs/call
40}
41
42#-----------------------------------------------------------------------------
43
44
# spent 27.1ms (10.7+16.4) within Perl::Critic::Policy::Modules::RequireFilenameMatchesPackage::violates which was called 144 times, avg 188µs/call: # 144 times (10.7ms+16.4ms) by Perl::Critic::_critique at line 183 of Perl/Critic.pm, avg 188µs/call
sub violates {
4514463µs my ($self, $elem, $doc) = @_;
46
47 # 'Foo::Bar' -> ('Foo', 'Bar')
48144294µs1442.00ms my $pkg_node = $doc->find_first('PPI::Statement::Package');
# spent 2.00ms making 144 calls to Perl::Critic::Document::find_first, avg 14µs/call
49144462µs14498µs return if not $pkg_node;
# spent 98µs making 144 calls to PPI::Util::TRUE, avg 682ns/call
50144376µs1446.42ms my $pkg = $pkg_node->namespace();
# spent 6.42ms making 144 calls to PPI::Statement::Package::namespace, avg 45µs/call
5114466µs return if $pkg eq 'main';
521441.19ms my @pkg_parts = split m/(?:\'|::)/xms, $pkg;
53
54
55 # 'lib/Foo/Bar.pm' -> ('lib', 'Foo', 'Bar')
56144421µs1443.55ms my $filename = $pkg_node->logical_filename() || $doc->filename();
# spent 3.55ms making 144 calls to PPI::Element::logical_filename, avg 25µs/call
5714442µs return if not $filename;
58
59144974µs1442.27ms my @path = File::Spec->splitpath($filename);
# spent 2.27ms making 144 calls to File::Spec::Unix::splitpath, avg 16µs/call
6014450µs $filename = $path[2];
61144800µs144372µs $filename =~ s/ [.] \w+ \z //xms;
# spent 372µs making 144 calls to Perl::Critic::Policy::Modules::RequireFilenameMatchesPackage::CORE:subst, avg 3µs/call
62 my @path_parts =
631442.79ms11521.71ms grep {$_ ne $EMPTY} File::Spec->splitdir($path[1]), $filename;
# spent 1.21ms making 1008 calls to Readonly::Scalar::FETCH, avg 1µs/call # spent 500µs making 144 calls to File::Spec::Unix::splitdir, avg 3µs/call
64
65
66 # To succeed, at least the lastmost must match
67 # Beyond that, the search terminates if a dirname is an impossible package name
6814427µs my $matched_any;
69144216µs while (@pkg_parts && @path_parts) {
70720230µs my $pkg_part = pop @pkg_parts;
71720162µs my $path_part = pop @path_parts;
72720118µs if ($pkg_part eq $path_part) {
7372071µs $matched_any = 1;
74720135µs next;
75 }
76
77 # if it's a path that's not a possible package (like 'Foo-Bar-1.00'), that's OK
78 last if ($path_part =~ m/\W/xms);
79
80 # Mismatched name
81 return $self->violation( $DESC, $EXPL, $pkg_node );
82 }
83
84144528µs return if $matched_any;
85 return $self->violation( $DESC, $EXPL, $pkg_node );
86}
87
8813µs1;
89
90#-----------------------------------------------------------------------------
91
92__END__
 
# spent 372µs within Perl::Critic::Policy::Modules::RequireFilenameMatchesPackage::CORE:subst which was called 144 times, avg 3µs/call: # 144 times (372µs+0s) by Perl::Critic::Policy::Modules::RequireFilenameMatchesPackage::violates at line 61, avg 3µs/call
sub Perl::Critic::Policy::Modules::RequireFilenameMatchesPackage::CORE:subst; # opcode