← 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/Behavior/Enumeration.pm
StatementsExecuted 167 statements in 755µs
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
811146µs196µsPerl::Critic::PolicyParameter::Behavior::Enumeration::::initialize_parameterPerl::Critic::PolicyParameter::Behavior::Enumeration::initialize_parameter
51190µs160µsPerl::Critic::PolicyParameter::Behavior::Enumeration::::__ANON__[:93]Perl::Critic::PolicyParameter::Behavior::Enumeration::__ANON__[:93]
31142µs76µsPerl::Critic::PolicyParameter::Behavior::Enumeration::::__ANON__[:127]Perl::Critic::PolicyParameter::Behavior::Enumeration::__ANON__[:127]
11115µs15µsPerl::Critic::PolicyParameter::Behavior::Enumeration::::BEGIN@10Perl::Critic::PolicyParameter::Behavior::Enumeration::BEGIN@10
11112µs16µsPerl::Critic::PolicyParameter::Behavior::Enumeration::::BEGIN@12Perl::Critic::PolicyParameter::Behavior::Enumeration::BEGIN@12
1117µs57µsPerl::Critic::PolicyParameter::Behavior::Enumeration::::BEGIN@18Perl::Critic::PolicyParameter::Behavior::Enumeration::BEGIN@18
1117µs290µsPerl::Critic::PolicyParameter::Behavior::Enumeration::::BEGIN@16Perl::Critic::PolicyParameter::Behavior::Enumeration::BEGIN@16
1117µs73µsPerl::Critic::PolicyParameter::Behavior::Enumeration::::BEGIN@15Perl::Critic::PolicyParameter::Behavior::Enumeration::BEGIN@15
1117µs18µsPerl::Critic::PolicyParameter::Behavior::Enumeration::::BEGIN@11Perl::Critic::PolicyParameter::Behavior::Enumeration::BEGIN@11
0000s0sPerl::Critic::PolicyParameter::Behavior::Enumeration::::generate_parameter_descriptionPerl::Critic::PolicyParameter::Behavior::Enumeration::generate_parameter_description
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::Behavior::Enumeration;
9
10240µs115µs
# spent 15µs within Perl::Critic::PolicyParameter::Behavior::Enumeration::BEGIN@10 which was called: # once (15µs+0s) by Perl::Critic::PolicyParameter::BEGIN@25 at line 10
use 5.006001;
11219µs230µs
# spent 18µs (7+11) within Perl::Critic::PolicyParameter::Behavior::Enumeration::BEGIN@11 which was called: # once (7µs+11µs) by Perl::Critic::PolicyParameter::BEGIN@25 at line 11
use strict;
# spent 18µs making 1 call to Perl::Critic::PolicyParameter::Behavior::Enumeration::BEGIN@11 # spent 12µs making 1 call to strict::import
12221µs219µs
# spent 16µs (12+4) within Perl::Critic::PolicyParameter::Behavior::Enumeration::BEGIN@12 which was called: # once (12µs+4µs) by Perl::Critic::PolicyParameter::BEGIN@25 at line 12
use warnings;
# spent 16µs making 1 call to Perl::Critic::PolicyParameter::Behavior::Enumeration::BEGIN@12 # spent 4µs making 1 call to warnings::import
13
14use Perl::Critic::Exception::Fatal::PolicyDefinition
15224µs2139µs
# spent 73µs (7+66) within Perl::Critic::PolicyParameter::Behavior::Enumeration::BEGIN@15 which was called: # once (7µs+66µs) by Perl::Critic::PolicyParameter::BEGIN@25 at line 15
qw{ &throw_policy_definition };
# spent 73µs making 1 call to Perl::Critic::PolicyParameter::Behavior::Enumeration::BEGIN@15 # spent 66µs making 1 call to Exporter::import
16227µs2574µs
# spent 290µs (7+283) within Perl::Critic::PolicyParameter::Behavior::Enumeration::BEGIN@16 which was called: # once (7µs+283µs) by Perl::Critic::PolicyParameter::BEGIN@25 at line 16
use Perl::Critic::Utils qw{ :characters &words_from_string &hashify };
# spent 290µs making 1 call to Perl::Critic::PolicyParameter::Behavior::Enumeration::BEGIN@16 # spent 283µs making 1 call to Exporter::import
17
182421µs257µs
# spent 57µs (7+50) within Perl::Critic::PolicyParameter::Behavior::Enumeration::BEGIN@18 which was called: # once (7µs+50µs) by Perl::Critic::PolicyParameter::BEGIN@25 at line 18
use base qw{ Perl::Critic::PolicyParameter::Behavior };
# spent 57µs making 1 call to Perl::Critic::PolicyParameter::Behavior::Enumeration::BEGIN@18 # spent 50µs making 1 call to base::import, recursion: max depth 1, sum of overlapping time 50µs
19
201600nsour $VERSION = '1.121';
21
22#-----------------------------------------------------------------------------
23
24
# spent 196µs (146+50) within Perl::Critic::PolicyParameter::Behavior::Enumeration::initialize_parameter which was called 8 times, avg 24µs/call: # 8 times (146µs+50µs) by Perl::Critic::PolicyParameter::_initialize_from_behavior at line 115 of Perl/Critic/PolicyParameter.pm, avg 24µs/call
sub initialize_parameter {
2582µs my ($self, $parameter, $specification) = @_;
26
2783µs my $valid_values = $specification->{enumeration_values}
28 or throw_policy_definition
29 'No enumeration_values given for '
30 . $parameter->get_name()
31 . $PERIOD;
3284µs ref $valid_values eq 'ARRAY'
33 or throw_policy_definition
34 'The value given for enumeration_values for '
35 . $parameter->get_name()
36 . ' is not an array reference.';
3783µs scalar @{$valid_values} > 1
38 or throw_policy_definition
39 'There were not at least two valid values given for'
40 . ' enumeration_values for '
41 . $parameter->get_name()
42 . $PERIOD;
43
44 # Unfortunately, this has to be a reference, rather than a regular hash,
45 # due to a problem in Devel::Cycle
46 # (http://rt.cpan.org/Ticket/Display.html?id=25360) which causes
47 # t/92_memory_leaks.t to fall over.
48833µs826µs my $value_lookup = { hashify( @{$valid_values} ) };
# spent 26µs making 8 calls to Perl::Critic::Utils::hashify, avg 3µs/call
49814µs810µs $parameter->_get_behavior_values()->{enumeration_values} = $value_lookup;
# spent 10µs making 8 calls to Perl::Critic::PolicyParameter::_get_behavior_values, avg 1µs/call
50
5183µs my $allow_multiple_values =
52 $specification->{enumeration_allow_multiple_values};
53
5483µs if ($allow_multiple_values) {
55 $parameter->_set_parser(
56
# spent 160µs (90+70) within 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] which was called 5 times, avg 32µs/call: # 5 times (90µs+70µs) by Perl::Critic::PolicyParameter::parse_and_validate_config_value at line 231 of Perl/Critic/PolicyParameter.pm, avg 32µs/call
sub {
57 # Normally bad thing, obscuring a variable in a outer scope
58 # with a variable with the same name is being done here in
59 # order to remain consistent with the parser function interface.
6051µs my ($policy, $parameter, $config_string) = @_; ## no critic(Variables::ProhibitReusedNames)
61
625500ns my @potential_values;
6356µs56µs my $value_string = $parameter->get_default_string();
# spent 6µs making 5 calls to Perl::Critic::PolicyParameter::get_default_string, avg 1µs/call
64
655800ns if (defined $config_string) {
66 $value_string = $config_string;
67 }
68
6952µs if ( defined $value_string ) {
7058µs510µs @potential_values = words_from_string($value_string);
# spent 10µs making 5 calls to Perl::Critic::Utils::words_from_string, avg 2µs/call
71
72 my @bad_values =
7355µs grep { not exists $value_lookup->{$_} } @potential_values;
7452µs if (@bad_values) {
75 $policy->throw_parameter_value_exception(
76 $parameter->get_name(),
77 $value_string,
78 undef,
79 q{contains invalid values: }
80 . join (q{, }, @bad_values)
81 . q{. Allowed values are: }
82 . join (q{, }, sort keys %{$value_lookup})
83 . qq{.\n},
84 );
85 }
86 }
87
8859µs57µs my %actual_values = hashify(@potential_values);
# spent 7µs making 5 calls to Perl::Critic::Utils::hashify, avg 1µs/call
89
90514µs546µs $policy->__set_parameter_value($parameter, \%actual_values);
# spent 46µs making 5 calls to Perl::Critic::Policy::__set_parameter_value, avg 9µs/call
91
92513µs return;
93 }
94518µs58µs );
# spent 8µs making 5 calls to Perl::Critic::PolicyParameter::_set_parser, avg 2µs/call
95 } else {
96 $parameter->_set_parser(
97
# spent 76µs (42+34) within 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] which was called 3 times, avg 25µs/call: # 3 times (42µs+34µs) by Perl::Critic::PolicyParameter::parse_and_validate_config_value at line 231 of Perl/Critic/PolicyParameter.pm, avg 25µs/call
sub {
98 # Normally bad thing, obscuring a variable in a outer scope
99 # with a variable with the same name is being done here in
100 # order to remain consistent with the parser function interface.
1013900ns my ($policy, $parameter, $config_string) = @_; ## no critic(Variables::ProhibitReusedNames)
102
10334µs34µs my $value_string = $parameter->get_default_string();
# spent 4µs making 3 calls to Perl::Critic::PolicyParameter::get_default_string, avg 1µs/call
104
1053600ns if (defined $config_string) {
106 $value_string = $config_string;
107 }
108
10938µs34µs if (
# spent 4µs making 3 calls to Readonly::Scalar::FETCH, avg 1µs/call
110 defined $value_string
111 and $EMPTY ne $value_string
112 and not defined $value_lookup->{$value_string}
113 ) {
114 $policy->throw_parameter_value_exception(
115 $parameter->get_name(),
116 $value_string,
117 undef,
118 q{is not one of the allowed values: }
119 . join (q{, }, sort keys %{$value_lookup})
120 . qq{.\n},
121 );
122 }
123
12436µs327µs $policy->__set_parameter_value($parameter, $value_string);
# spent 27µs making 3 calls to Perl::Critic::Policy::__set_parameter_value, avg 9µs/call
125
12638µs return;
127 }
128312µs35µs );
# spent 5µs making 3 calls to Perl::Critic::PolicyParameter::_set_parser, avg 2µs/call
129 }
130
131819µs return;
132}
133
134#-----------------------------------------------------------------------------
135
136sub generate_parameter_description {
137 my ($self, $parameter) = @_;
138
139 my $description = $parameter->_get_description_with_trailing_period();
140 if ( $description ) {
141 $description .= qq{\n};
142 }
143
144 my %values = %{$parameter->_get_behavior_values()->{enumeration_values}};
145 return
146 $description
147 . 'Valid values: '
148 . join (', ', sort keys %values)
149 . $PERIOD;
150}
151
152#-----------------------------------------------------------------------------
153
15412µs1;
155
156__END__