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

Filename/Users/timbo/perl5/perlbrew/perls/perl-5.18.2/lib/site_perl/5.18.2/Perl/Critic/UserProfile.pm
StatementsExecuted 2649 statements in 4.41ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
141111.09ms8.91msPerl::Critic::UserProfile::::policy_paramsPerl::Critic::UserProfile::policy_params
1111.05ms5.38msPerl::Critic::UserProfile::::BEGIN@20Perl::Critic::UserProfile::BEGIN@20
141111.03ms3.98msPerl::Critic::UserProfile::::raw_policy_paramsPerl::Critic::UserProfile::raw_policy_params
14111742µs2.56msPerl::Critic::UserProfile::::policy_is_disabledPerl::Critic::UserProfile::policy_is_disabled
111728µs761µsPerl::Critic::UserProfile::::BEGIN@17Perl::Critic::UserProfile::BEGIN@17
14111649µs2.30msPerl::Critic::UserProfile::::policy_is_enabledPerl::Critic::UserProfile::policy_is_enabled
11129µs187µsPerl::Critic::UserProfile::::_load_profile_from_filePerl::Critic::UserProfile::_load_profile_from_file
137120µs20µsPerl::Critic::UserProfile::::sourcePerl::Critic::UserProfile::source
11116µs625µsPerl::Critic::UserProfile::::_initPerl::Critic::UserProfile::_init
11116µs205µsPerl::Critic::UserProfile::::_load_profilePerl::Critic::UserProfile::_load_profile
11115µs15µsPerl::Critic::UserProfile::::BEGIN@10Perl::Critic::UserProfile::BEGIN@10
11114µs400µsPerl::Critic::UserProfile::::_set_options_processorPerl::Critic::UserProfile::_set_options_processor
88111µs11µsPerl::Critic::UserProfile::::options_processorPerl::Critic::UserProfile::options_processor
11111µs45µsPerl::Critic::UserProfile::::BEGIN@23Perl::Critic::UserProfile::BEGIN@23
11111µs11µsPerl::Critic::UserProfile::::listed_policiesPerl::Critic::UserProfile::listed_policies
11110µs15µsPerl::Critic::UserProfile::::BEGIN@12Perl::Critic::UserProfile::BEGIN@12
11110µs635µsPerl::Critic::UserProfile::::newPerl::Critic::UserProfile::new
1119µs30µsPerl::Critic::UserProfile::::BEGIN@22Perl::Critic::UserProfile::BEGIN@22
1118µs274µsPerl::Critic::UserProfile::::BEGIN@21Perl::Critic::UserProfile::BEGIN@21
1118µs26µsPerl::Critic::UserProfile::::BEGIN@15Perl::Critic::UserProfile::BEGIN@15
1117µs394µsPerl::Critic::UserProfile::::BEGIN@14Perl::Critic::UserProfile::BEGIN@14
1116µs6µsPerl::Critic::UserProfile::::BEGIN@24Perl::Critic::UserProfile::BEGIN@24
1116µs6µsPerl::Critic::UserProfile::::_fix_defaults_keyPerl::Critic::UserProfile::_fix_defaults_key
1116µs17µsPerl::Critic::UserProfile::::BEGIN@11Perl::Critic::UserProfile::BEGIN@11
1116µs6µsPerl::Critic::UserProfile::::_set_sourcePerl::Critic::UserProfile::_set_source
1115µs5µsPerl::Critic::UserProfile::::BEGIN@18Perl::Critic::UserProfile::BEGIN@18
1114µs4µsPerl::Critic::UserProfile::::_find_profile_pathPerl::Critic::UserProfile::_find_profile_path
111400ns400nsPerl::Critic::UserProfile::::CORE:sortPerl::Critic::UserProfile::CORE:sort (opcode)
0000s0sPerl::Critic::UserProfile::::_find_home_dirPerl::Critic::UserProfile::_find_home_dir
0000s0sPerl::Critic::UserProfile::::_load_profile_from_arrayPerl::Critic::UserProfile::_load_profile_from_array
0000s0sPerl::Critic::UserProfile::::_load_profile_from_hashPerl::Critic::UserProfile::_load_profile_from_hash
0000s0sPerl::Critic::UserProfile::::_load_profile_from_stringPerl::Critic::UserProfile::_load_profile_from_string
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::UserProfile;
9
10238µs115µs
# spent 15µs within Perl::Critic::UserProfile::BEGIN@10 which was called: # once (15µs+0s) by Perl::Critic::Config::BEGIN@26 at line 10
use 5.006001;
# spent 15µs making 1 call to Perl::Critic::UserProfile::BEGIN@10
11219µs228µs
# spent 17µs (6+11) within Perl::Critic::UserProfile::BEGIN@11 which was called: # once (6µs+11µs) by Perl::Critic::Config::BEGIN@26 at line 11
use strict;
# spent 17µs making 1 call to Perl::Critic::UserProfile::BEGIN@11 # spent 11µs making 1 call to strict::import
12221µs220µs
# spent 15µs (10+5) within Perl::Critic::UserProfile::BEGIN@12 which was called: # once (10µs+5µs) by Perl::Critic::Config::BEGIN@26 at line 12
use warnings;
# spent 15µs making 1 call to Perl::Critic::UserProfile::BEGIN@12 # spent 5µs making 1 call to warnings::import
13
14226µs2780µs
# spent 394µs (7+387) within Perl::Critic::UserProfile::BEGIN@14 which was called: # once (7µs+387µs) by Perl::Critic::Config::BEGIN@26 at line 14
use English qw(-no_match_vars);
# spent 394µs making 1 call to Perl::Critic::UserProfile::BEGIN@14 # spent 387µs making 1 call to English::import
15220µs244µs
# spent 26µs (8+18) within Perl::Critic::UserProfile::BEGIN@15 which was called: # once (8µs+18µs) by Perl::Critic::Config::BEGIN@26 at line 15
use Readonly;
# spent 26µs making 1 call to Perl::Critic::UserProfile::BEGIN@15 # spent 18µs making 1 call to Exporter::import
16
17289µs1761µs
# spent 761µs (728+33) within Perl::Critic::UserProfile::BEGIN@17 which was called: # once (728µs+33µs) by Perl::Critic::Config::BEGIN@26 at line 17
use Config::Tiny qw();
# spent 761µs making 1 call to Perl::Critic::UserProfile::BEGIN@17
18220µs15µs
# spent 5µs within Perl::Critic::UserProfile::BEGIN@18 which was called: # once (5µs+0s) by Perl::Critic::Config::BEGIN@26 at line 18
use File::Spec qw();
# spent 5µs making 1 call to Perl::Critic::UserProfile::BEGIN@18
19
20293µs15.38ms
# spent 5.38ms (1.05+4.33) within Perl::Critic::UserProfile::BEGIN@20 which was called: # once (1.05ms+4.33ms) by Perl::Critic::Config::BEGIN@26 at line 20
use Perl::Critic::OptionsProcessor qw();
# spent 5.38ms making 1 call to Perl::Critic::UserProfile::BEGIN@20
21225µs2541µs
# spent 274µs (8+266) within Perl::Critic::UserProfile::BEGIN@21 which was called: # once (8µs+266µs) by Perl::Critic::Config::BEGIN@26 at line 21
use Perl::Critic::Utils qw{ :characters policy_long_name policy_short_name };
# spent 274µs making 1 call to Perl::Critic::UserProfile::BEGIN@21 # spent 266µs making 1 call to Exporter::import
22224µs251µs
# spent 30µs (9+21) within Perl::Critic::UserProfile::BEGIN@22 which was called: # once (9µs+21µs) by Perl::Critic::Config::BEGIN@26 at line 22
use Perl::Critic::Exception::Fatal::Internal qw{ throw_internal };
# spent 30µs making 1 call to Perl::Critic::UserProfile::BEGIN@22 # spent 21µs making 1 call to Exporter::import
23225µs280µs
# spent 45µs (11+34) within Perl::Critic::UserProfile::BEGIN@23 which was called: # once (11µs+34µs) by Perl::Critic::Config::BEGIN@26 at line 23
use Perl::Critic::Exception::Configuration::Generic qw{ throw_generic };
# spent 45µs making 1 call to Perl::Critic::UserProfile::BEGIN@23 # spent 34µs making 1 call to Exporter::import
242913µs16µs
# spent 6µs within Perl::Critic::UserProfile::BEGIN@24 which was called: # once (6µs+0s) by Perl::Critic::Config::BEGIN@26 at line 24
use Perl::Critic::PolicyConfig;
# spent 6µs making 1 call to Perl::Critic::UserProfile::BEGIN@24
25
261600nsour $VERSION = '1.121';
27
28#-----------------------------------------------------------------------------
29
30
# spent 635µs (10+625) within Perl::Critic::UserProfile::new which was called: # once (10µs+625µs) by Perl::Critic::Config::_init at line 70 of Perl/Critic/Config.pm
sub new {
31
3211µs my ( $class, %args ) = @_;
3311µs my $self = bless {}, $class;
3413µs1625µs $self->_init( %args );
# spent 625µs making 1 call to Perl::Critic::UserProfile::_init
3516µs return $self;
36}
37
38#-----------------------------------------------------------------------------
39
40
# spent 625µs (16+609) within Perl::Critic::UserProfile::_init which was called: # once (16µs+609µs) by Perl::Critic::UserProfile::new at line 34
sub _init {
41
421800ns my ( $self, %args ) = @_;
43 # The profile can be defined, undefined, or an empty string.
4413µs14µs my $profile = defined $args{-profile} ? $args{-profile} : _find_profile_path();
# spent 4µs making 1 call to Perl::Critic::UserProfile::_find_profile_path
4513µs1205µs $self->_load_profile( $profile );
# spent 205µs making 1 call to Perl::Critic::UserProfile::_load_profile
4612µs1400µs $self->_set_options_processor();
# spent 400µs making 1 call to Perl::Critic::UserProfile::_set_options_processor
4714µs return $self;
48}
49
50#-----------------------------------------------------------------------------
51
52
# spent 11µs within Perl::Critic::UserProfile::options_processor which was called 8 times, avg 1µs/call: # once (2µs+0s) by Perl::Critic::Config::_init at line 71 of Perl/Critic/Config.pm # once (2µs+0s) by Perl::Critic::Config::_validate_and_save_verbosity at line 484 of Perl/Critic/Config.pm # once (1µs+0s) by Perl::Critic::Config::_validate_and_save_profile_strictness at line 443 of Perl/Critic/Config.pm # once (1µs+0s) by Perl::Critic::Config::_validate_and_save_pager at line 685 of Perl/Critic/Config.pm # once (1µs+0s) by Perl::Critic::Config::_validate_and_save_theme at line 623 of Perl/Critic/Config.pm # once (1µs+0s) by Perl::Critic::Config::_validate_and_save_program_extensions at line 765 of Perl/Critic/Config.pm # once (1µs+0s) by Perl::Critic::Config::_validate_and_save_severity at line 526 of Perl/Critic/Config.pm # once (1µs+0s) by Perl::Critic::Config::_validate_and_save_top at line 585 of Perl/Critic/Config.pm
sub options_processor {
53
5481µs my ($self) = @_;
55824µs return $self->{_options_processor};
56}
57
58#-----------------------------------------------------------------------------
59
60
# spent 8.91ms (1.09+7.83) within Perl::Critic::UserProfile::policy_params which was called 141 times, avg 63µs/call: # 141 times (1.09ms+7.83ms) by Perl::Critic::PolicyFactory::create_policy at line 198 of Perl/Critic/PolicyFactory.pm, avg 63µs/call
sub policy_params {
61
6214130µs my ( $self, $policy ) = @_;
63
64141137µs1411.48ms my $short_name = policy_short_name($policy);
# spent 1.48ms making 141 calls to Perl::Critic::Utils::policy_short_name, avg 10µs/call
65
66141609µs2826.35ms return Perl::Critic::PolicyConfig->new(
# spent 3.98ms making 141 calls to Perl::Critic::UserProfile::raw_policy_params, avg 28µs/call # spent 2.37ms making 141 calls to Perl::Critic::PolicyConfig::new, avg 17µs/call
67 $short_name,
68 $self->raw_policy_params($policy),
69 );
70}
71
72#-----------------------------------------------------------------------------
73
74
# spent 3.98ms (1.03+2.95) within Perl::Critic::UserProfile::raw_policy_params which was called 141 times, avg 28µs/call: # 141 times (1.03ms+2.95ms) by Perl::Critic::UserProfile::policy_params at line 66, avg 28µs/call
sub raw_policy_params {
75
7614133µs my ( $self, $policy ) = @_;
7714144µs my $profile = $self->{_profile};
78141153µs1411.44ms my $long_name = ref $policy || policy_long_name( $policy );
# spent 1.44ms making 141 calls to Perl::Critic::Utils::policy_long_name, avg 10µs/call
79141164µs1411.51ms my $short_name = policy_short_name( $long_name );
# spent 1.51ms making 141 calls to Perl::Critic::Utils::policy_short_name, avg 11µs/call
80
81 return
82141467µs $profile->{$short_name}
83 || $profile->{$long_name}
84 || $profile->{"-$short_name"}
85 || $profile->{"-$long_name"}
86 || {};
87}
88
89#-----------------------------------------------------------------------------
90
91
# spent 2.56ms (742µs+1.82) within Perl::Critic::UserProfile::policy_is_disabled which was called 141 times, avg 18µs/call: # 141 times (742µs+1.82ms) by Perl::Critic::Config::_policy_is_disabled at line 265 of Perl/Critic/Config.pm, avg 18µs/call
sub policy_is_disabled {
92
9314136µs my ( $self, $policy ) = @_;
9414132µs my $profile = $self->{_profile};
9514149µs my $long_name = ref $policy || policy_long_name( $policy );
96141164µs1411.82ms my $short_name = policy_short_name( $long_name );
# spent 1.82ms making 141 calls to Perl::Critic::Utils::policy_short_name, avg 13µs/call
97
98141419µs return exists $profile->{"-$short_name"}
99 || exists $profile->{"-$long_name"};
100}
101
102#-----------------------------------------------------------------------------
103
104
# spent 2.30ms (649µs+1.65) within Perl::Critic::UserProfile::policy_is_enabled which was called 141 times, avg 16µs/call: # 141 times (649µs+1.65ms) by Perl::Critic::Config::_policy_is_enabled at line 273 of Perl/Critic/Config.pm, avg 16µs/call
sub policy_is_enabled {
105
10614124µs my ( $self, $policy ) = @_;
10714132µs my $profile = $self->{_profile};
10814143µs my $long_name = ref $policy || policy_long_name( $policy );
109141148µs1411.65ms my $short_name = policy_short_name( $long_name );
# spent 1.65ms making 141 calls to Perl::Critic::Utils::policy_short_name, avg 12µs/call
110
111141343µs return exists $profile->{$short_name}
112 || exists $profile->{$long_name};
113}
114
115#-----------------------------------------------------------------------------
116
117
# spent 11µs (11+400ns) within Perl::Critic::UserProfile::listed_policies which was called: # once (11µs+400ns) by Perl::Critic::PolicyFactory::_validate_policies_in_profile at line 307 of Perl/Critic/PolicyFactory.pm
sub listed_policies {
118
1191500ns my ( $self, $policy ) = @_;
1201400ns my @normalized_policy_names = ();
121
12218µs1400ns for my $policy_name ( sort keys %{$self->{_profile}} ) {
# spent 400ns making 1 call to Perl::Critic::UserProfile::CORE:sort
123 $policy_name =~ s/\A - //xmso; #Chomp leading "-"
124 my $policy_long_name = policy_long_name( $policy_name );
125 push @normalized_policy_names, $policy_long_name;
126 }
127
12814µs return @normalized_policy_names;
129}
130
131#-----------------------------------------------------------------------------
132
133
# spent 20µs within Perl::Critic::UserProfile::source which was called 13 times, avg 2µs/call: # 5 times (8µs+0s) by Perl::Critic::Config::_validate_and_save_color_severity at line 713 of Perl/Critic/Config.pm, avg 2µs/call # 3 times (4µs+0s) by Perl::Critic::Config::_validate_and_save_regex at line 384 of Perl/Critic/Config.pm, avg 1µs/call # once (2µs+0s) by Perl::Critic::Config::_validate_and_save_profile_strictness at line 442 of Perl/Critic/Config.pm # once (1µs+0s) by Perl::Critic::Config::_validate_and_save_theme at line 622 of Perl/Critic/Config.pm # once (1µs+0s) by Perl::Critic::Config::_validate_and_save_severity at line 525 of Perl/Critic/Config.pm # once (1µs+0s) by Perl::Critic::Config::_validate_and_save_verbosity at line 483 of Perl/Critic/Config.pm # once (1µs+0s) by Perl::Critic::Config::_validate_and_save_top at line 584 of Perl/Critic/Config.pm
sub source {
134132µs my ( $self ) = @_;
135
1361334µs return $self->{_source};
137}
138
139
# spent 6µs within Perl::Critic::UserProfile::_set_source which was called: # once (6µs+0s) by Perl::Critic::UserProfile::_load_profile_from_file at line 194
sub _set_source {
1401600ns my ( $self, $source ) = @_;
141
14214µs $self->{_source} = $source;
143
14413µs return;
145}
146
147#-----------------------------------------------------------------------------
148# Begin PRIVATE methods
149
15013µs140µsReadonly::Hash my %LOADER_FOR => (
# spent 40µs making 1 call to Readonly::Hash
151 ARRAY => \&_load_profile_from_array,
152 DEFAULT => \&_load_profile_from_file,
153 HASH => \&_load_profile_from_hash,
154 SCALAR => \&_load_profile_from_string,
155);
156
157
# spent 205µs (16+189) within Perl::Critic::UserProfile::_load_profile which was called: # once (16µs+189µs) by Perl::Critic::UserProfile::_init at line 45
sub _load_profile {
158
1591600ns my ( $self, $profile ) = @_;
160
1611600ns my $ref_type = ref $profile || 'DEFAULT';
16215µs12µs my $loader = $LOADER_FOR{$ref_type};
# spent 2µs making 1 call to Readonly::Hash::FETCH
163
1641400ns if (not $loader) {
165 throw_internal qq{Can't load UserProfile from type "$ref_type"};
166 }
167
16813µs1187µs $self->{_profile} = $loader->($self, $profile);
# spent 187µs making 1 call to Perl::Critic::UserProfile::_load_profile_from_file
16913µs return $self;
170}
171
172#-----------------------------------------------------------------------------
173
174
# spent 400µs (14+386) within Perl::Critic::UserProfile::_set_options_processor which was called: # once (14µs+386µs) by Perl::Critic::UserProfile::_init at line 46
sub _set_options_processor {
175
1761400ns my ($self) = @_;
1771500ns my $profile = $self->{_profile};
1781900ns my $defaults = delete $profile->{__defaults__} || {};
179 $self->{_options_processor} =
18015µs1386µs Perl::Critic::OptionsProcessor->new( %{ $defaults } );
# spent 386µs making 1 call to Perl::Critic::OptionsProcessor::new
18114µs return $self;
182}
183
184#-----------------------------------------------------------------------------
185
186
# spent 187µs (29+159) within Perl::Critic::UserProfile::_load_profile_from_file which was called: # once (29µs+159µs) by Perl::Critic::UserProfile::_load_profile at line 168
sub _load_profile_from_file {
1871800ns my ( $self, $file ) = @_;
188
189 # Handle special cases.
1901300ns return {} if not defined $file;
19114µs12µs return {} if $file eq $EMPTY;
# spent 2µs making 1 call to Readonly::Scalar::FETCH
1921400ns return {} if $file eq 'NONE';
193
19412µs16µs $self->_set_source( $file );
# spent 6µs making 1 call to Perl::Critic::UserProfile::_set_source
195
19614µs1144µs my $profile = Config::Tiny->read( $file );
# spent 144µs making 1 call to Config::Tiny::read
1971300ns if (not defined $profile) {
198 my $errstr = Config::Tiny::errstr();
199 throw_generic
200 message => qq{Could not parse profile "$file": $errstr},
201 source => $file;
202 }
203
20412µs16µs _fix_defaults_key( $profile );
# spent 6µs making 1 call to Perl::Critic::UserProfile::_fix_defaults_key
205
20614µs return $profile;
207}
208
209#-----------------------------------------------------------------------------
210
211sub _load_profile_from_array {
212 my ( $self, $array_ref ) = @_;
213 my $joined = join qq{\n}, @{ $array_ref };
214 my $profile = Config::Tiny->read_string( $joined );
215
216 if (not defined $profile) {
217 throw_generic 'Profile error: ' . Config::Tiny::errstr();
218 }
219
220 _fix_defaults_key( $profile );
221
222 return $profile;
223}
224
225#-----------------------------------------------------------------------------
226
227sub _load_profile_from_string {
228 my ( $self, $string ) = @_;
229 my $profile = Config::Tiny->read_string( ${ $string } );
230
231 if (not defined $profile) {
232 throw_generic 'Profile error: ' . Config::Tiny::errstr();
233 }
234
235 _fix_defaults_key( $profile );
236
237 return $profile;
238}
239
240#-----------------------------------------------------------------------------
241
242sub _load_profile_from_hash {
243 my ( $self, $hash_ref ) = @_;
244 return $hash_ref;
245}
246
247#-----------------------------------------------------------------------------
248
249
# spent 4µs within Perl::Critic::UserProfile::_find_profile_path which was called: # once (4µs+0s) by Perl::Critic::UserProfile::_init at line 44
sub _find_profile_path {
250
251 #Define default filename
2521500ns my $rc_file = '.perlcriticrc';
253
254 #Check explicit environment setting
25515µs return $ENV{PERLCRITIC} if exists $ENV{PERLCRITIC};
256
257 #Check current directory
258 return $rc_file if -f $rc_file;
259
260 #Check home directory
261 if ( my $home_dir = _find_home_dir() ) {
262 my $path = File::Spec->catfile( $home_dir, $rc_file );
263 return $path if -f $path;
264 }
265
266 #No profile defined
267 return;
268}
269
270#-----------------------------------------------------------------------------
271
272sub _find_home_dir {
273
274 # Try using File::HomeDir
275 if ( eval { require File::HomeDir } ) {
276 return File::HomeDir->my_home();
277 }
278
279 # Check usual environment vars
280 for my $key (qw(HOME USERPROFILE HOMESHARE)) {
281 next if not defined $ENV{$key};
282 return $ENV{$key} if -d $ENV{$key};
283 }
284
285 # No home directory defined
286 return;
287}
288
289#-----------------------------------------------------------------------------
290
291# !$%@$%^ Config::Tiny uses a completely non-descriptive name for global
292# values.
293
# spent 6µs within Perl::Critic::UserProfile::_fix_defaults_key which was called: # once (6µs+0s) by Perl::Critic::UserProfile::_load_profile_from_file at line 204
sub _fix_defaults_key {
2941500ns my ( $profile ) = @_;
295
29613µs my $defaults = delete $profile->{_};
2971300ns if ($defaults) {
298 $profile->{__defaults__} = $defaults;
299 }
300
30117µs return;
302}
303
30414µs1;
305
306__END__
 
# spent 400ns within Perl::Critic::UserProfile::CORE:sort which was called: # once (400ns+0s) by Perl::Critic::UserProfile::listed_policies at line 122
sub Perl::Critic::UserProfile::CORE:sort; # opcode