← 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/PolicyParameter.pm
StatementsExecuted 5873 statements in 13.6ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
9711867µs3.94msPerl::Critic::PolicyParameter::::parse_and_validate_config_valuePerl::Critic::PolicyParameter::parse_and_validate_config_value
9711856µs1.34msPerl::Critic::PolicyParameter::::_finish_standard_initializationPerl::Critic::PolicyParameter::_finish_standard_initialization
9711850µs4.70msPerl::Critic::PolicyParameter::::newPerl::Critic::PolicyParameter::new
9711685µs2.51msPerl::Critic::PolicyParameter::::_initialize_from_behaviorPerl::Critic::PolicyParameter::_initialize_from_behavior
9721597µs747µsPerl::Critic::PolicyParameter::::_get_behavior_for_namePerl::Critic::PolicyParameter::_get_behavior_for_name
111587µs1.06msPerl::Critic::PolicyParameter::::BEGIN@25Perl::Critic::PolicyParameter::BEGIN@25
111477µs830µsPerl::Critic::PolicyParameter::::BEGIN@26Perl::Critic::PolicyParameter::BEGIN@26
111367µs757µsPerl::Critic::PolicyParameter::::BEGIN@28Perl::Critic::PolicyParameter::BEGIN@28
28132366µs366µsPerl::Critic::PolicyParameter::::get_namePerl::Critic::PolicyParameter::get_name
19476311µs311µsPerl::Critic::PolicyParameter::::_set_parserPerl::Critic::PolicyParameter::_set_parser
111278µs1.34msPerl::Critic::PolicyParameter::::BEGIN@24Perl::Critic::PolicyParameter::BEGIN@24
111264µs584µsPerl::Critic::PolicyParameter::::BEGIN@23Perl::Critic::PolicyParameter::BEGIN@23
111248µs1.27msPerl::Critic::PolicyParameter::::BEGIN@27Perl::Critic::PolicyParameter::BEGIN@27
9711177µs177µsPerl::Critic::PolicyParameter::::_set_default_stringPerl::Critic::PolicyParameter::_set_default_string
9711169µs169µsPerl::Critic::PolicyParameter::::_set_descriptionPerl::Critic::PolicyParameter::_set_description
9711121µs121µsPerl::Critic::PolicyParameter::::_get_parserPerl::Critic::PolicyParameter::_get_parser
8898117µs117µsPerl::Critic::PolicyParameter::::get_default_stringPerl::Critic::PolicyParameter::get_default_string
684380µs80µsPerl::Critic::PolicyParameter::::_get_behavior_valuesPerl::Critic::PolicyParameter::_get_behavior_values
11114µs14µsPerl::Critic::PolicyParameter::::BEGIN@10Perl::Critic::PolicyParameter::BEGIN@10
11112µs31µsPerl::Critic::PolicyParameter::::BEGIN@22Perl::Critic::PolicyParameter::BEGIN@22
1117µs263µsPerl::Critic::PolicyParameter::::BEGIN@30Perl::Critic::PolicyParameter::BEGIN@30
1117µs18µsPerl::Critic::PolicyParameter::::BEGIN@11Perl::Critic::PolicyParameter::BEGIN@11
1117µs30µsPerl::Critic::PolicyParameter::::BEGIN@19Perl::Critic::PolicyParameter::BEGIN@19
1117µs11µsPerl::Critic::PolicyParameter::::BEGIN@15Perl::Critic::PolicyParameter::BEGIN@15
1117µs66µsPerl::Critic::PolicyParameter::::BEGIN@31Perl::Critic::PolicyParameter::BEGIN@31
1117µs10µsPerl::Critic::PolicyParameter::::BEGIN@12Perl::Critic::PolicyParameter::BEGIN@12
1116µs24µsPerl::Critic::PolicyParameter::::BEGIN@13Perl::Critic::PolicyParameter::BEGIN@13
0000s0sPerl::Critic::PolicyParameter::::__ANON__[:270]Perl::Critic::PolicyParameter::__ANON__[:270]
0000s0sPerl::Critic::PolicyParameter::::__ANON__[:271]Perl::Critic::PolicyParameter::__ANON__[:271]
0000s0sPerl::Critic::PolicyParameter::::__ANON__[:272]Perl::Critic::PolicyParameter::__ANON__[:272]
0000s0sPerl::Critic::PolicyParameter::::__ANON__[:273]Perl::Critic::PolicyParameter::__ANON__[:273]
0000s0sPerl::Critic::PolicyParameter::::_generate_full_descriptionPerl::Critic::PolicyParameter::_generate_full_description
0000s0sPerl::Critic::PolicyParameter::::_get_behaviorPerl::Critic::PolicyParameter::_get_behavior
0000s0sPerl::Critic::PolicyParameter::::_get_description_with_trailing_periodPerl::Critic::PolicyParameter::_get_description_with_trailing_period
0000s0sPerl::Critic::PolicyParameter::::generate_full_descriptionPerl::Critic::PolicyParameter::generate_full_description
0000s0sPerl::Critic::PolicyParameter::::get_descriptionPerl::Critic::PolicyParameter::get_description
0000s0sPerl::Critic::PolicyParameter::::to_formatted_stringPerl::Critic::PolicyParameter::to_formatted_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::PolicyParameter;
9
10238µs114µs
# spent 14µs within Perl::Critic::PolicyParameter::BEGIN@10 which was called: # once (14µs+0s) by Perl::Critic::Policy::BEGIN@45 at line 10
use 5.006001;
# spent 14µs making 1 call to Perl::Critic::PolicyParameter::BEGIN@10
11217µs230µs
# spent 18µs (7+11) within Perl::Critic::PolicyParameter::BEGIN@11 which was called: # once (7µs+11µs) by Perl::Critic::Policy::BEGIN@45 at line 11
use strict;
# spent 18µs making 1 call to Perl::Critic::PolicyParameter::BEGIN@11 # spent 11µs making 1 call to strict::import
12216µs214µs
# spent 10µs (7+4) within Perl::Critic::PolicyParameter::BEGIN@12 which was called: # once (7µs+4µs) by Perl::Critic::Policy::BEGIN@45 at line 12
use warnings;
# spent 10µs making 1 call to Perl::Critic::PolicyParameter::BEGIN@12 # spent 4µs making 1 call to warnings::import
13219µs242µs
# spent 24µs (6+18) within Perl::Critic::PolicyParameter::BEGIN@13 which was called: # once (6µs+18µs) by Perl::Critic::Policy::BEGIN@45 at line 13
use Readonly;
# spent 24µs making 1 call to Perl::Critic::PolicyParameter::BEGIN@13 # spent 18µs making 1 call to Exporter::import
14
15231µs216µs
# spent 11µs (7+4) within Perl::Critic::PolicyParameter::BEGIN@15 which was called: # once (7µs+4µs) by Perl::Critic::Policy::BEGIN@45 at line 15
use Exporter 'import';
# spent 11µs making 1 call to Perl::Critic::PolicyParameter::BEGIN@15 # spent 4µs making 1 call to Exporter::import
16
1712µs128µsReadonly::Array our @EXPORT_OK => qw{ $NO_DESCRIPTION_AVAILABLE };
# spent 28µs making 1 call to Readonly::Array
18
19224µs252µs
# spent 30µs (7+23) within Perl::Critic::PolicyParameter::BEGIN@19 which was called: # once (7µs+23µs) by Perl::Critic::Policy::BEGIN@45 at line 19
use String::Format qw{ stringf };
# spent 30µs making 1 call to Perl::Critic::PolicyParameter::BEGIN@19 # spent 23µs making 1 call to Exporter::import
20
21use Perl::Critic::Exception::Fatal::PolicyDefinition
22218µs250µs
# spent 31µs (12+19) within Perl::Critic::PolicyParameter::BEGIN@22 which was called: # once (12µs+19µs) by Perl::Critic::Policy::BEGIN@45 at line 22
qw{ throw_policy_definition };
# spent 31µs making 1 call to Perl::Critic::PolicyParameter::BEGIN@22 # spent 19µs making 1 call to Exporter::import
232112µs1584µs
# spent 584µs (264+320) within Perl::Critic::PolicyParameter::BEGIN@23 which was called: # once (264µs+320µs) by Perl::Critic::Policy::BEGIN@45 at line 23
use Perl::Critic::PolicyParameter::Behavior;
# spent 584µs making 1 call to Perl::Critic::PolicyParameter::BEGIN@23
24295µs11.34ms
# spent 1.34ms (278µs+1.07) within Perl::Critic::PolicyParameter::BEGIN@24 which was called: # once (278µs+1.07ms) by Perl::Critic::Policy::BEGIN@45 at line 24
use Perl::Critic::PolicyParameter::Behavior::Boolean;
# spent 1.34ms making 1 call to Perl::Critic::PolicyParameter::BEGIN@24
25285µs11.06ms
# spent 1.06ms (587µs+469µs) within Perl::Critic::PolicyParameter::BEGIN@25 which was called: # once (587µs+469µs) by Perl::Critic::Policy::BEGIN@45 at line 25
use Perl::Critic::PolicyParameter::Behavior::Enumeration;
# spent 1.06ms making 1 call to Perl::Critic::PolicyParameter::BEGIN@25
26295µs1830µs
# spent 830µs (477+354) within Perl::Critic::PolicyParameter::BEGIN@26 which was called: # once (477µs+354µs) by Perl::Critic::Policy::BEGIN@45 at line 26
use Perl::Critic::PolicyParameter::Behavior::Integer;
# spent 830µs making 1 call to Perl::Critic::PolicyParameter::BEGIN@26
27290µs11.27ms
# spent 1.27ms (248µs+1.02) within Perl::Critic::PolicyParameter::BEGIN@27 which was called: # once (248µs+1.02ms) by Perl::Critic::Policy::BEGIN@45 at line 27
use Perl::Critic::PolicyParameter::Behavior::String;
# spent 1.27ms making 1 call to Perl::Critic::PolicyParameter::BEGIN@27
28285µs1757µs
# spent 757µs (367+390) within Perl::Critic::PolicyParameter::BEGIN@28 which was called: # once (367µs+390µs) by Perl::Critic::Policy::BEGIN@45 at line 28
use Perl::Critic::PolicyParameter::Behavior::StringList;
# spent 757µs making 1 call to Perl::Critic::PolicyParameter::BEGIN@28
29
30224µs2518µs
# spent 263µs (7+255) within Perl::Critic::PolicyParameter::BEGIN@30 which was called: # once (7µs+255µs) by Perl::Critic::Policy::BEGIN@45 at line 30
use Perl::Critic::Utils qw{ :characters &interpolate };
# spent 263µs making 1 call to Perl::Critic::PolicyParameter::BEGIN@30 # spent 255µs making 1 call to Exporter::import
312792µs2124µs
# spent 66µs (7+59) within Perl::Critic::PolicyParameter::BEGIN@31 which was called: # once (7µs+59µs) by Perl::Critic::Policy::BEGIN@45 at line 31
use Perl::Critic::Utils::DataConversion qw{ &defined_or_empty };
# spent 66µs making 1 call to Perl::Critic::PolicyParameter::BEGIN@31 # spent 59µs making 1 call to Exporter::import
32
331300nsour $VERSION = '1.121';
34
3511µs132µsReadonly::Scalar our $NO_DESCRIPTION_AVAILABLE => 'No description available.';
# spent 32µs making 1 call to Readonly::Scalar
36
37#-----------------------------------------------------------------------------
38
39# Grrr... one of the OO limitations of Perl: you can't put references to
40# subclases in a superclass (well, not nicely). This map and method belong
41# in Behavior.pm.
42114µs645µsReadonly::Hash my %BEHAVIORS =>
# spent 36µs making 1 call to Readonly::Hash # spent 9µs making 5 calls to Perl::Critic::PolicyParameter::Behavior::new, avg 2µs/call
43 (
44 'boolean' => Perl::Critic::PolicyParameter::Behavior::Boolean->new(),
45 'enumeration' => Perl::Critic::PolicyParameter::Behavior::Enumeration->new(),
46 'integer' => Perl::Critic::PolicyParameter::Behavior::Integer->new(),
47 'string' => Perl::Critic::PolicyParameter::Behavior::String->new(),
48 'string list' => Perl::Critic::PolicyParameter::Behavior::StringList->new(),
49 );
50
51
# spent 747µs (597+149) within Perl::Critic::PolicyParameter::_get_behavior_for_name which was called 97 times, avg 8µs/call: # 86 times (526µs+132µs) by Perl::Critic::PolicyParameter::_initialize_from_behavior at line 106, avg 8µs/call # 11 times (71µs+17µs) by Perl::Critic::PolicyParameter::_initialize_from_behavior at line 109, avg 8µs/call
sub _get_behavior_for_name {
529713µs my $behavior_name = shift;
53
5497342µs97149µs my $behavior = $BEHAVIORS{$behavior_name}
# spent 149µs making 97 calls to Readonly::Hash::FETCH, avg 2µs/call
55 or throw_policy_definition qq{There's no "$behavior_name" behavior.};
56
5797194µs return $behavior;
58}
59
60#-----------------------------------------------------------------------------
61
62
# spent 4.70ms (850µs+3.85) within Perl::Critic::PolicyParameter::new which was called 97 times, avg 48µs/call: # 97 times (850µs+3.85ms) by Perl::Critic::Policy::new at line 86 of Perl/Critic/Policy.pm, avg 48µs/call
sub new {
639729µs my ($class, $specification) = @_;
649785µs my $self = bless {}, $class;
65
669715µs defined $specification
67 or throw_policy_definition
68 'Attempt to create a ', __PACKAGE__, ' without a specification.';
69
70971µs my $behavior_specification;
71
729727µs my $specification_type = ref $specification;
739717µs if ( not $specification_type ) {
74 $self->{_name} = $specification;
75
76 $behavior_specification = {};
77 } else {
789717µs $specification_type eq 'HASH'
79 or throw_policy_definition
80 'Attempt to create a ',
81 __PACKAGE__,
82 " with a $specification_type as a specification.",
83 ;
84
859721µs defined $specification->{name}
86 or throw_policy_definition
87 'Attempt to create a ', __PACKAGE__, ' without a name.';
889765µs $self->{_name} = $specification->{name};
89
909716µs $behavior_specification = $specification;
91 }
92
939786µs972.51ms $self->_initialize_from_behavior($behavior_specification);
# spent 2.51ms making 97 calls to Perl::Critic::PolicyParameter::_initialize_from_behavior, avg 26µs/call
949791µs971.34ms $self->_finish_standard_initialization($behavior_specification);
# spent 1.34ms making 97 calls to Perl::Critic::PolicyParameter::_finish_standard_initialization, avg 14µs/call
95
96973.48ms return $self;
97}
98
99# See if the specification includes a Behavior name, and if so, let the
100# Behavior with that name plug in its implementations of parser, etc.
101
# spent 2.51ms (685µs+1.82) within Perl::Critic::PolicyParameter::_initialize_from_behavior which was called 97 times, avg 26µs/call: # 97 times (685µs+1.82ms) by Perl::Critic::PolicyParameter::new at line 93, avg 26µs/call
sub _initialize_from_behavior {
1029717µs my ($self, $specification) = @_;
103
1049721µs my $behavior_name = $specification->{behavior};
105972µs my $behavior;
1069785µs86658µs if ($behavior_name) {
# spent 658µs making 86 calls to Perl::Critic::PolicyParameter::_get_behavior_for_name, avg 8µs/call
107 $behavior = _get_behavior_for_name($behavior_name);
108 } else {
1091111µs1188µs $behavior = _get_behavior_for_name('string');
# spent 88µs making 11 calls to Perl::Critic::PolicyParameter::_get_behavior_for_name, avg 8µs/call
110 }
111
1129732µs $self->{_behavior} = $behavior;
1139736µs $self->{_behavior_values} = {};
114
11597116µs971.08ms $behavior->initialize_parameter($self, $specification);
# spent 383µs making 32 calls to Perl::Critic::PolicyParameter::Behavior::StringList::initialize_parameter, avg 12µs/call # spent 242µs making 14 calls to Perl::Critic::PolicyParameter::Behavior::Integer::initialize_parameter, avg 17µs/call # spent 196µs making 8 calls to Perl::Critic::PolicyParameter::Behavior::Enumeration::initialize_parameter, avg 24µs/call # spent 131µs making 20 calls to Perl::Critic::PolicyParameter::Behavior::Boolean::initialize_parameter, avg 7µs/call # spent 126µs making 23 calls to Perl::Critic::PolicyParameter::Behavior::String::initialize_parameter, avg 5µs/call
116
11797156µs return;
118}
119
120# Grab the rest of the values out of the specification, including overrides
121# of what the Behavior specified.
122
# spent 1.34ms (856µs+483µs) within Perl::Critic::PolicyParameter::_finish_standard_initialization which was called 97 times, avg 14µs/call: # 97 times (856µs+483µs) by Perl::Critic::PolicyParameter::new at line 94, avg 14µs/call
sub _finish_standard_initialization {
1239721µs my ($self, $specification) = @_;
124
1259735µs my $description =
126 $specification->{description} || $NO_DESCRIPTION_AVAILABLE;
1279773µs97169µs $self->_set_description($description);
# spent 169µs making 97 calls to Perl::Critic::PolicyParameter::_set_description, avg 2µs/call
12897104µs97177µs $self->_set_default_string($specification->{default_string});
# spent 177µs making 97 calls to Perl::Critic::PolicyParameter::_set_default_string, avg 2µs/call
129
13097168µs97136µs $self->_set_parser($specification->{parser});
# spent 136µs making 97 calls to Perl::Critic::PolicyParameter::_set_parser, avg 1µs/call
131
13297175µs return;
133}
134
135#-----------------------------------------------------------------------------
136
137
# spent 366µs within Perl::Critic::PolicyParameter::get_name which was called 281 times, avg 1µs/call: # 97 times (132µs+0s) by Perl::Critic::Policy::new at line 103 of Perl/Critic/Policy.pm, avg 1µs/call # 97 times (128µs+0s) by Perl::Critic::PolicyParameter::parse_and_validate_config_value at line 228, avg 1µs/call # 87 times (106µs+0s) by Perl::Critic::Policy::__get_parameter_name at line 140 of Perl/Critic/Policy.pm, avg 1µs/call
sub get_name {
13828141µs my $self = shift;
139
1402814.32ms return $self->{_name};
141}
142
143#-----------------------------------------------------------------------------
144
145sub get_description {
146 my $self = shift;
147
148 return $self->{_description};
149}
150
151
# spent 169µs within Perl::Critic::PolicyParameter::_set_description which was called 97 times, avg 2µs/call: # 97 times (169µs+0s) by Perl::Critic::PolicyParameter::_finish_standard_initialization at line 127, avg 2µs/call
sub _set_description {
1529721µs my ($self, $new_value) = @_;
153
1549711µs return if not defined $new_value;
1559748µs $self->{_description} = $new_value;
156
15797165µs return;
158}
159
160sub _get_description_with_trailing_period {
161 my $self = shift;
162
163 my $description = $self->get_description();
164 if ($description) {
165 if ( $PERIOD ne substr $description, ( length $description ) - 1 ) {
166 $description .= $PERIOD;
167 }
168 } else {
169 $description = $EMPTY;
170 }
171
172 return $description;
173}
174
175#-----------------------------------------------------------------------------
176
177
# spent 117µs within Perl::Critic::PolicyParameter::get_default_string which was called 88 times, avg 1µs/call: # 32 times (43µs+0s) by Perl::Critic::PolicyParameter::Behavior::StringList::__ANON__[/Users/timbo/perl5/perlbrew/perls/perl-5.18.2/lib/site_perl/5.18.2/Perl/Critic/PolicyParameter/Behavior/StringList.pm:60] at line 45 of Perl/Critic/PolicyParameter/Behavior/StringList.pm, avg 1µs/call # 20 times (28µs+0s) by Perl::Critic::PolicyParameter::Behavior::Boolean::_parse at line 25 of Perl/Critic/PolicyParameter/Behavior/Boolean.pm, avg 1µs/call # 14 times (19µs+0s) by Perl::Critic::PolicyParameter::Behavior::Integer::__ANON__[/Users/timbo/perl5/perlbrew/perls/perl-5.18.2/lib/site_perl/5.18.2/Perl/Critic/PolicyParameter/Behavior/Integer.pm:82] at line 38 of Perl/Critic/PolicyParameter/Behavior/Integer.pm, avg 1µs/call # 11 times (13µs+0s) by Perl::Critic::PolicyParameter::Behavior::String::_parse at line 25 of Perl/Critic/PolicyParameter/Behavior/String.pm, avg 1µs/call # 5 times (6µs+0s) by Perl::Critic::PolicyParameter::Behavior::Enumeration::__ANON__[/Users/timbo/perl5/perlbrew/perls/perl-5.18.2/lib/site_perl/5.18.2/Perl/Critic/PolicyParameter/Behavior/Enumeration.pm:93] at line 63 of Perl/Critic/PolicyParameter/Behavior/Enumeration.pm, avg 1µs/call # 3 times (4µs+0s) by Perl::Critic::PolicyParameter::Behavior::Enumeration::__ANON__[/Users/timbo/perl5/perlbrew/perls/perl-5.18.2/lib/site_perl/5.18.2/Perl/Critic/PolicyParameter/Behavior/Enumeration.pm:127] at line 103 of Perl/Critic/PolicyParameter/Behavior/Enumeration.pm, avg 1µs/call # once (2µs+0s) by Perl::Critic::Policy::Subroutines::ProtectPrivateSubs::_parse_private_name_regex at line 102 of Perl/Critic/Policy/Subroutines/ProtectPrivateSubs.pm # once (1µs+0s) by Perl::Critic::Policy::Modules::ProhibitEvilModules::_parse_modules at line 111 of Perl/Critic/Policy/Modules/ProhibitEvilModules.pm # once (1µs+0s) by Perl::Critic::Policy::Subroutines::ProhibitUnusedPrivateSubroutines::_parse_private_name_regex at line 63 of Perl/Critic/Policy/Subroutines/ProhibitUnusedPrivateSubroutines.pm
sub get_default_string {
1788811µs my $self = shift;
179
18088219µs return $self->{_default_string};
181}
182
183
# spent 177µs within Perl::Critic::PolicyParameter::_set_default_string which was called 97 times, avg 2µs/call: # 97 times (177µs+0s) by Perl::Critic::PolicyParameter::_finish_standard_initialization at line 128, avg 2µs/call
sub _set_default_string {
1849725µs my ($self, $new_value) = @_;
185
1869726µs return if not defined $new_value;
1878845µs $self->{_default_string} = $new_value;
188
18988146µs return;
190}
191
192#-----------------------------------------------------------------------------
193
194sub _get_behavior {
195 my $self = shift;
196
197 return $self->{_behavior};
198}
199
200
# spent 80µs within Perl::Critic::PolicyParameter::_get_behavior_values which was called 68 times, avg 1µs/call: # 32 times (36µs+0s) by Perl::Critic::PolicyParameter::Behavior::StringList::initialize_parameter at line 30 of Perl/Critic/PolicyParameter/Behavior/StringList.pm, avg 1µs/call # 14 times (19µs+0s) by Perl::Critic::PolicyParameter::Behavior::Integer::initialize_parameter at line 28 of Perl/Critic/PolicyParameter/Behavior/Integer.pm, avg 1µs/call # 14 times (15µs+0s) by Perl::Critic::PolicyParameter::Behavior::Integer::initialize_parameter at line 29 of Perl/Critic/PolicyParameter/Behavior/Integer.pm, avg 1µs/call # 8 times (10µs+0s) by Perl::Critic::PolicyParameter::Behavior::Enumeration::initialize_parameter at line 49 of Perl/Critic/PolicyParameter/Behavior/Enumeration.pm, avg 1µs/call
sub _get_behavior_values {
201689µs my $self = shift;
202
20368142µs return $self->{_behavior_values};
204}
205
206#-----------------------------------------------------------------------------
207
208
# spent 121µs within Perl::Critic::PolicyParameter::_get_parser which was called 97 times, avg 1µs/call: # 97 times (121µs+0s) by Perl::Critic::PolicyParameter::parse_and_validate_config_value at line 230, avg 1µs/call
sub _get_parser {
2099713µs my $self = shift;
210
21197189µs return $self->{_parser};
212}
213
214
# spent 311µs within Perl::Critic::PolicyParameter::_set_parser which was called 194 times, avg 2µs/call: # 97 times (136µs+0s) by Perl::Critic::PolicyParameter::_finish_standard_initialization at line 130, avg 1µs/call # 32 times (54µs+0s) by Perl::Critic::PolicyParameter::Behavior::StringList::initialize_parameter at line 61 of Perl/Critic/PolicyParameter/Behavior/StringList.pm, avg 2µs/call # 23 times (36µs+0s) by Perl::Critic::PolicyParameter::Behavior::String::initialize_parameter at line 41 of Perl/Critic/PolicyParameter/Behavior/String.pm, avg 2µs/call # 20 times (44µs+0s) by Perl::Critic::PolicyParameter::Behavior::Boolean::initialize_parameter at line 47 of Perl/Critic/PolicyParameter/Behavior/Boolean.pm, avg 2µs/call # 14 times (26µs+0s) by Perl::Critic::PolicyParameter::Behavior::Integer::initialize_parameter at line 83 of Perl/Critic/PolicyParameter/Behavior/Integer.pm, avg 2µs/call # 5 times (8µs+0s) by Perl::Critic::PolicyParameter::Behavior::Enumeration::initialize_parameter at line 94 of Perl/Critic/PolicyParameter/Behavior/Enumeration.pm, avg 2µs/call # 3 times (5µs+0s) by Perl::Critic::PolicyParameter::Behavior::Enumeration::initialize_parameter at line 128 of Perl/Critic/PolicyParameter/Behavior/Enumeration.pm, avg 2µs/call
sub _set_parser {
21519461µs my ($self, $new_value) = @_;
216
217194167µs return if not defined $new_value;
21810930µs $self->{_parser} = $new_value;
219
220109224µs return;
221}
222
223#-----------------------------------------------------------------------------
224
225
# spent 3.94ms (867µs+3.07) within Perl::Critic::PolicyParameter::parse_and_validate_config_value which was called 97 times, avg 41µs/call: # 97 times (867µs+3.07ms) by Perl::Critic::Policy::new at line 97 of Perl/Critic/Policy.pm, avg 41µs/call
sub parse_and_validate_config_value {
2269724µs my ($self, $policy, $config) = @_;
227
22897120µs97128µs my $config_string = $config->{$self->get_name()};
# spent 128µs making 97 calls to Perl::Critic::PolicyParameter::get_name, avg 1µs/call
229
23097112µs97121µs my $parser = $self->_get_parser();
# spent 121µs making 97 calls to Perl::Critic::PolicyParameter::_get_parser, avg 1µs/call
23197127µs972.82ms if ($parser) {
# spent 1.08ms making 32 calls to Perl::Critic::PolicyParameter::Behavior::StringList::__ANON__[Perl/Critic/PolicyParameter/Behavior/StringList.pm:60], avg 34µs/call # spent 527µs making 20 calls to Perl::Critic::PolicyParameter::Behavior::Boolean::_parse, avg 26µs/call # spent 418µs making 14 calls to Perl::Critic::PolicyParameter::Behavior::Integer::__ANON__[Perl/Critic/PolicyParameter/Behavior/Integer.pm:82], avg 30µs/call # spent 196µs making 11 calls to Perl::Critic::PolicyParameter::Behavior::String::_parse, avg 18µs/call # spent 186µs making 1 call to Perl::Critic::Policy::Modules::ProhibitEvilModules::_parse_modules # spent 160µs making 5 calls to Perl::Critic::PolicyParameter::Behavior::Enumeration::__ANON__[Perl/Critic/PolicyParameter/Behavior/Enumeration.pm:93], avg 32µs/call # spent 76µs making 3 calls to Perl::Critic::PolicyParameter::Behavior::Enumeration::__ANON__[Perl/Critic/PolicyParameter/Behavior/Enumeration.pm:127], avg 25µs/call # spent 58µs making 1 call to Perl::Critic::Policy::ValuesAndExpressions::ProhibitMagicNumbers::_parse_allowed_values # spent 50µs making 1 call to Perl::Critic::Policy::Subroutines::ProhibitUnusedPrivateSubroutines::_parse_private_name_regex # spent 46µs making 1 call to Perl::Critic::Policy::Subroutines::ProtectPrivateSubs::_parse_private_name_regex # spent 6µs making 1 call to Perl::Critic::Policy::ValuesAndExpressions::ProhibitInterpolationOfLiterals::_parse_allow # spent 6µs making 1 call to Perl::Critic::Policy::TestingAndDebugging::ProhibitNoStrict::_parse_allow # spent 4µs making 1 call to Perl::Critic::Policy::TestingAndDebugging::ProhibitNoWarnings::_parse_allow # spent 3µs making 1 call to Perl::Critic::Policy::Variables::ProhibitEvilVariables::_parse_variables # spent 3µs making 1 call to Perl::Critic::Policy::Documentation::RequirePodSections::_parse_lib_sections # spent 2µs making 1 call to Perl::Critic::Policy::Documentation::RequirePodSections::_parse_script_sections # spent 2µs making 1 call to Perl::Critic::Policy::Modules::ProhibitEvilModules::_parse_modules_file # spent 2µs making 1 call to Perl::Critic::Policy::Variables::ProhibitEvilVariables::_parse_variables_file
232 $parser->($policy, $self, $config_string);
233 }
234
23597158µs return;
236}
237
238#-----------------------------------------------------------------------------
239
240sub generate_full_description {
241 my ($self) = @_;
242
243 return $self->_get_behavior()->generate_parameter_description($self);
244}
245
246#-----------------------------------------------------------------------------
247
248sub _generate_full_description {
249 my ($self, $prefix) = @_;
250
251 my $description = $self->generate_full_description();
252
253 if (not $description) {
254 return $EMPTY;
255 }
256
257 if ($prefix) {
258 $description =~ s/ ^ /$prefix/xmsg;
259 }
260
261 return $description;
262}
263
264#-----------------------------------------------------------------------------
265
266sub to_formatted_string {
267 my ($self, $format) = @_;
268
269 my %specification = (
270 n => sub { $self->get_name() },
271 d => sub { defined_or_empty( $self->get_description() ) },
272 D => sub { defined_or_empty( $self->get_default_string() ) },
273 f => sub { $self->_generate_full_description(@_) },
274 );
275
276 return stringf( interpolate($format), %specification );
277}
278
279#-----------------------------------------------------------------------------
280
28116µs1;
282
283__END__