Filename | /Users/timbo/perl5/perlbrew/perls/perl-5.18.2/lib/site_perl/5.18.2/Perl/Critic/PolicyParameter.pm |
Statements | Executed 5873 statements in 13.6ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
97 | 1 | 1 | 867µs | 3.94ms | parse_and_validate_config_value | Perl::Critic::PolicyParameter::
97 | 1 | 1 | 856µs | 1.34ms | _finish_standard_initialization | Perl::Critic::PolicyParameter::
97 | 1 | 1 | 850µs | 4.70ms | new | Perl::Critic::PolicyParameter::
97 | 1 | 1 | 685µs | 2.51ms | _initialize_from_behavior | Perl::Critic::PolicyParameter::
97 | 2 | 1 | 597µs | 747µs | _get_behavior_for_name | Perl::Critic::PolicyParameter::
1 | 1 | 1 | 587µs | 1.06ms | BEGIN@25 | Perl::Critic::PolicyParameter::
1 | 1 | 1 | 477µs | 830µs | BEGIN@26 | Perl::Critic::PolicyParameter::
1 | 1 | 1 | 367µs | 757µs | BEGIN@28 | Perl::Critic::PolicyParameter::
281 | 3 | 2 | 366µs | 366µs | get_name | Perl::Critic::PolicyParameter::
194 | 7 | 6 | 311µs | 311µs | _set_parser | Perl::Critic::PolicyParameter::
1 | 1 | 1 | 278µs | 1.34ms | BEGIN@24 | Perl::Critic::PolicyParameter::
1 | 1 | 1 | 264µs | 584µs | BEGIN@23 | Perl::Critic::PolicyParameter::
1 | 1 | 1 | 248µs | 1.27ms | BEGIN@27 | Perl::Critic::PolicyParameter::
97 | 1 | 1 | 177µs | 177µs | _set_default_string | Perl::Critic::PolicyParameter::
97 | 1 | 1 | 169µs | 169µs | _set_description | Perl::Critic::PolicyParameter::
97 | 1 | 1 | 121µs | 121µs | _get_parser | Perl::Critic::PolicyParameter::
88 | 9 | 8 | 117µs | 117µs | get_default_string | Perl::Critic::PolicyParameter::
68 | 4 | 3 | 80µs | 80µs | _get_behavior_values | Perl::Critic::PolicyParameter::
1 | 1 | 1 | 14µs | 14µs | BEGIN@10 | Perl::Critic::PolicyParameter::
1 | 1 | 1 | 12µs | 31µs | BEGIN@22 | Perl::Critic::PolicyParameter::
1 | 1 | 1 | 7µs | 263µs | BEGIN@30 | Perl::Critic::PolicyParameter::
1 | 1 | 1 | 7µs | 18µs | BEGIN@11 | Perl::Critic::PolicyParameter::
1 | 1 | 1 | 7µs | 30µs | BEGIN@19 | Perl::Critic::PolicyParameter::
1 | 1 | 1 | 7µs | 11µs | BEGIN@15 | Perl::Critic::PolicyParameter::
1 | 1 | 1 | 7µs | 66µs | BEGIN@31 | Perl::Critic::PolicyParameter::
1 | 1 | 1 | 7µs | 10µs | BEGIN@12 | Perl::Critic::PolicyParameter::
1 | 1 | 1 | 6µs | 24µs | BEGIN@13 | Perl::Critic::PolicyParameter::
0 | 0 | 0 | 0s | 0s | __ANON__[:270] | Perl::Critic::PolicyParameter::
0 | 0 | 0 | 0s | 0s | __ANON__[:271] | Perl::Critic::PolicyParameter::
0 | 0 | 0 | 0s | 0s | __ANON__[:272] | Perl::Critic::PolicyParameter::
0 | 0 | 0 | 0s | 0s | __ANON__[:273] | Perl::Critic::PolicyParameter::
0 | 0 | 0 | 0s | 0s | _generate_full_description | Perl::Critic::PolicyParameter::
0 | 0 | 0 | 0s | 0s | _get_behavior | Perl::Critic::PolicyParameter::
0 | 0 | 0 | 0s | 0s | _get_description_with_trailing_period | Perl::Critic::PolicyParameter::
0 | 0 | 0 | 0s | 0s | generate_full_description | Perl::Critic::PolicyParameter::
0 | 0 | 0 | 0s | 0s | get_description | Perl::Critic::PolicyParameter::
0 | 0 | 0 | 0s | 0s | to_formatted_string | Perl::Critic::PolicyParameter::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | ############################################################################## | ||||
2 | # $URL$ | ||||
3 | # $Date$ | ||||
4 | # $Author$ | ||||
5 | # $Revision$ | ||||
6 | ############################################################################## | ||||
7 | |||||
8 | package Perl::Critic::PolicyParameter; | ||||
9 | |||||
10 | 2 | 38µs | 1 | 14µ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 # spent 14µs making 1 call to Perl::Critic::PolicyParameter::BEGIN@10 |
11 | 2 | 17µs | 2 | 30µ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 # spent 18µs making 1 call to Perl::Critic::PolicyParameter::BEGIN@11
# spent 11µs making 1 call to strict::import |
12 | 2 | 16µs | 2 | 14µ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 # spent 10µs making 1 call to Perl::Critic::PolicyParameter::BEGIN@12
# spent 4µs making 1 call to warnings::import |
13 | 2 | 19µs | 2 | 42µ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 # spent 24µs making 1 call to Perl::Critic::PolicyParameter::BEGIN@13
# spent 18µs making 1 call to Exporter::import |
14 | |||||
15 | 2 | 31µs | 2 | 16µ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 # spent 11µs making 1 call to Perl::Critic::PolicyParameter::BEGIN@15
# spent 4µs making 1 call to Exporter::import |
16 | |||||
17 | 1 | 2µs | 1 | 28µs | Readonly::Array our @EXPORT_OK => qw{ $NO_DESCRIPTION_AVAILABLE }; # spent 28µs making 1 call to Readonly::Array |
18 | |||||
19 | 2 | 24µs | 2 | 52µ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 # spent 30µs making 1 call to Perl::Critic::PolicyParameter::BEGIN@19
# spent 23µs making 1 call to Exporter::import |
20 | |||||
21 | use Perl::Critic::Exception::Fatal::PolicyDefinition | ||||
22 | 2 | 18µs | 2 | 50µ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 # spent 31µs making 1 call to Perl::Critic::PolicyParameter::BEGIN@22
# spent 19µs making 1 call to Exporter::import |
23 | 2 | 112µs | 1 | 584µ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 # spent 584µs making 1 call to Perl::Critic::PolicyParameter::BEGIN@23 |
24 | 2 | 95µs | 1 | 1.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 # spent 1.34ms making 1 call to Perl::Critic::PolicyParameter::BEGIN@24 |
25 | 2 | 85µs | 1 | 1.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 # spent 1.06ms making 1 call to Perl::Critic::PolicyParameter::BEGIN@25 |
26 | 2 | 95µs | 1 | 830µ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 # spent 830µs making 1 call to Perl::Critic::PolicyParameter::BEGIN@26 |
27 | 2 | 90µs | 1 | 1.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 # spent 1.27ms making 1 call to Perl::Critic::PolicyParameter::BEGIN@27 |
28 | 2 | 85µs | 1 | 757µ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 # spent 757µs making 1 call to Perl::Critic::PolicyParameter::BEGIN@28 |
29 | |||||
30 | 2 | 24µs | 2 | 518µ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 # spent 263µs making 1 call to Perl::Critic::PolicyParameter::BEGIN@30
# spent 255µs making 1 call to Exporter::import |
31 | 2 | 792µs | 2 | 124µ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 # spent 66µs making 1 call to Perl::Critic::PolicyParameter::BEGIN@31
# spent 59µs making 1 call to Exporter::import |
32 | |||||
33 | 1 | 300ns | our $VERSION = '1.121'; | ||
34 | |||||
35 | 1 | 1µs | 1 | 32µs | Readonly::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. | ||||
42 | 1 | 14µs | 6 | 45µs | Readonly::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 | ||||
52 | 97 | 13µs | my $behavior_name = shift; | ||
53 | |||||
54 | 97 | 342µs | 97 | 149µ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 | |||||
57 | 97 | 194µ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 | ||||
63 | 97 | 29µs | my ($class, $specification) = @_; | ||
64 | 97 | 85µs | my $self = bless {}, $class; | ||
65 | |||||
66 | 97 | 15µs | defined $specification | ||
67 | or throw_policy_definition | ||||
68 | 'Attempt to create a ', __PACKAGE__, ' without a specification.'; | ||||
69 | |||||
70 | 97 | 1µs | my $behavior_specification; | ||
71 | |||||
72 | 97 | 27µs | my $specification_type = ref $specification; | ||
73 | 97 | 17µs | if ( not $specification_type ) { | ||
74 | $self->{_name} = $specification; | ||||
75 | |||||
76 | $behavior_specification = {}; | ||||
77 | } else { | ||||
78 | 97 | 17µ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 | |||||
85 | 97 | 21µs | defined $specification->{name} | ||
86 | or throw_policy_definition | ||||
87 | 'Attempt to create a ', __PACKAGE__, ' without a name.'; | ||||
88 | 97 | 65µs | $self->{_name} = $specification->{name}; | ||
89 | |||||
90 | 97 | 16µs | $behavior_specification = $specification; | ||
91 | } | ||||
92 | |||||
93 | 97 | 86µs | 97 | 2.51ms | $self->_initialize_from_behavior($behavior_specification); # spent 2.51ms making 97 calls to Perl::Critic::PolicyParameter::_initialize_from_behavior, avg 26µs/call |
94 | 97 | 91µs | 97 | 1.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 | |||||
96 | 97 | 3.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 | ||||
102 | 97 | 17µs | my ($self, $specification) = @_; | ||
103 | |||||
104 | 97 | 21µs | my $behavior_name = $specification->{behavior}; | ||
105 | 97 | 2µs | my $behavior; | ||
106 | 97 | 85µs | 86 | 658µ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 { | ||||
109 | 11 | 11µs | 11 | 88µ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 | |||||
112 | 97 | 32µs | $self->{_behavior} = $behavior; | ||
113 | 97 | 36µs | $self->{_behavior_values} = {}; | ||
114 | |||||
115 | 97 | 116µs | 97 | 1.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 | |||||
117 | 97 | 156µ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 | ||||
123 | 97 | 21µs | my ($self, $specification) = @_; | ||
124 | |||||
125 | 97 | 35µs | my $description = | ||
126 | $specification->{description} || $NO_DESCRIPTION_AVAILABLE; | ||||
127 | 97 | 73µs | 97 | 169µs | $self->_set_description($description); # spent 169µs making 97 calls to Perl::Critic::PolicyParameter::_set_description, avg 2µs/call |
128 | 97 | 104µs | 97 | 177µ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 | |||||
130 | 97 | 168µs | 97 | 136µs | $self->_set_parser($specification->{parser}); # spent 136µs making 97 calls to Perl::Critic::PolicyParameter::_set_parser, avg 1µs/call |
131 | |||||
132 | 97 | 175µ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 | ||||
138 | 281 | 41µs | my $self = shift; | ||
139 | |||||
140 | 281 | 4.32ms | return $self->{_name}; | ||
141 | } | ||||
142 | |||||
143 | #----------------------------------------------------------------------------- | ||||
144 | |||||
145 | sub 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 | ||||
152 | 97 | 21µs | my ($self, $new_value) = @_; | ||
153 | |||||
154 | 97 | 11µs | return if not defined $new_value; | ||
155 | 97 | 48µs | $self->{_description} = $new_value; | ||
156 | |||||
157 | 97 | 165µs | return; | ||
158 | } | ||||
159 | |||||
160 | sub _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 | ||||
178 | 88 | 11µs | my $self = shift; | ||
179 | |||||
180 | 88 | 219µ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 | ||||
184 | 97 | 25µs | my ($self, $new_value) = @_; | ||
185 | |||||
186 | 97 | 26µs | return if not defined $new_value; | ||
187 | 88 | 45µs | $self->{_default_string} = $new_value; | ||
188 | |||||
189 | 88 | 146µs | return; | ||
190 | } | ||||
191 | |||||
192 | #----------------------------------------------------------------------------- | ||||
193 | |||||
194 | sub _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 | ||||
201 | 68 | 9µs | my $self = shift; | ||
202 | |||||
203 | 68 | 142µ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 | ||||
209 | 97 | 13µs | my $self = shift; | ||
210 | |||||
211 | 97 | 189µ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 | ||||
215 | 194 | 61µs | my ($self, $new_value) = @_; | ||
216 | |||||
217 | 194 | 167µs | return if not defined $new_value; | ||
218 | 109 | 30µs | $self->{_parser} = $new_value; | ||
219 | |||||
220 | 109 | 224µ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 | ||||
226 | 97 | 24µs | my ($self, $policy, $config) = @_; | ||
227 | |||||
228 | 97 | 120µs | 97 | 128µ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 | |||||
230 | 97 | 112µs | 97 | 121µs | my $parser = $self->_get_parser(); # spent 121µs making 97 calls to Perl::Critic::PolicyParameter::_get_parser, avg 1µs/call |
231 | 97 | 127µs | 97 | 2.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 | |||||
235 | 97 | 158µs | return; | ||
236 | } | ||||
237 | |||||
238 | #----------------------------------------------------------------------------- | ||||
239 | |||||
240 | sub generate_full_description { | ||||
241 | my ($self) = @_; | ||||
242 | |||||
243 | return $self->_get_behavior()->generate_parameter_description($self); | ||||
244 | } | ||||
245 | |||||
246 | #----------------------------------------------------------------------------- | ||||
247 | |||||
248 | sub _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 | |||||
266 | sub 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 | |||||
281 | 1 | 6µs | 1; | ||
282 | |||||
283 | __END__ |