Filename | /Users/timbo/perl5/perlbrew/perls/perl-5.18.2/lib/site_perl/5.18.2/Perl/Critic/PolicyParameter/Behavior/Integer.pm |
Statements | Executed 278 statements in 762µs |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
14 | 1 | 1 | 213µs | 418µs | __ANON__[:82] | Perl::Critic::PolicyParameter::Behavior::Integer::
14 | 1 | 1 | 181µs | 242µs | initialize_parameter | Perl::Critic::PolicyParameter::Behavior::Integer::
14 | 1 | 1 | 26µs | 26µs | CORE:match (opcode) | Perl::Critic::PolicyParameter::Behavior::Integer::
1 | 1 | 1 | 15µs | 15µs | BEGIN@10 | Perl::Critic::PolicyParameter::Behavior::Integer::
1 | 1 | 1 | 8µs | 61µs | BEGIN@16 | Perl::Critic::PolicyParameter::Behavior::Integer::
1 | 1 | 1 | 7µs | 11µs | BEGIN@12 | Perl::Critic::PolicyParameter::Behavior::Integer::
1 | 1 | 1 | 7µs | 249µs | BEGIN@14 | Perl::Critic::PolicyParameter::Behavior::Integer::
1 | 1 | 1 | 6µs | 18µs | BEGIN@11 | Perl::Critic::PolicyParameter::Behavior::Integer::
0 | 0 | 0 | 0s | 0s | generate_parameter_description | Perl::Critic::PolicyParameter::Behavior::Integer::
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::Behavior::Integer; | ||||
9 | |||||
10 | 2 | 36µs | 1 | 15µs | # spent 15µs within Perl::Critic::PolicyParameter::Behavior::Integer::BEGIN@10 which was called:
# once (15µs+0s) by Perl::Critic::PolicyParameter::BEGIN@26 at line 10 # spent 15µs making 1 call to Perl::Critic::PolicyParameter::Behavior::Integer::BEGIN@10 |
11 | 2 | 19µs | 2 | 29µs | # spent 18µs (6+12) within Perl::Critic::PolicyParameter::Behavior::Integer::BEGIN@11 which was called:
# once (6µs+12µs) by Perl::Critic::PolicyParameter::BEGIN@26 at line 11 # spent 18µs making 1 call to Perl::Critic::PolicyParameter::Behavior::Integer::BEGIN@11
# spent 12µs making 1 call to strict::import |
12 | 2 | 23µs | 2 | 15µs | # spent 11µs (7+4) within Perl::Critic::PolicyParameter::Behavior::Integer::BEGIN@12 which was called:
# once (7µs+4µs) by Perl::Critic::PolicyParameter::BEGIN@26 at line 12 # spent 11µs making 1 call to Perl::Critic::PolicyParameter::Behavior::Integer::BEGIN@12
# spent 4µs making 1 call to warnings::import |
13 | |||||
14 | 2 | 24µs | 2 | 491µs | # spent 249µs (7+242) within Perl::Critic::PolicyParameter::Behavior::Integer::BEGIN@14 which was called:
# once (7µs+242µs) by Perl::Critic::PolicyParameter::BEGIN@26 at line 14 # spent 249µs making 1 call to Perl::Critic::PolicyParameter::Behavior::Integer::BEGIN@14
# spent 242µs making 1 call to Exporter::import |
15 | |||||
16 | 2 | 328µs | 2 | 61µs | # spent 61µs (8+53) within Perl::Critic::PolicyParameter::Behavior::Integer::BEGIN@16 which was called:
# once (8µs+53µs) by Perl::Critic::PolicyParameter::BEGIN@26 at line 16 # spent 61µs making 1 call to Perl::Critic::PolicyParameter::Behavior::Integer::BEGIN@16
# spent 53µs making 1 call to base::import, recursion: max depth 1, sum of overlapping time 53µs |
17 | |||||
18 | 1 | 600ns | our $VERSION = '1.121'; | ||
19 | |||||
20 | #----------------------------------------------------------------------------- | ||||
21 | |||||
22 | # spent 242µs (181+60) within Perl::Critic::PolicyParameter::Behavior::Integer::initialize_parameter which was called 14 times, avg 17µs/call:
# 14 times (181µs+60µs) by Perl::Critic::PolicyParameter::_initialize_from_behavior at line 115 of Perl/Critic/PolicyParameter.pm, avg 17µs/call | ||||
23 | 14 | 4µs | my ($self, $parameter, $specification) = @_; | ||
24 | |||||
25 | 14 | 5µs | my $minimum = $specification->{integer_minimum}; | ||
26 | 14 | 4µs | my $maximum = $specification->{integer_maximum}; | ||
27 | |||||
28 | 14 | 21µs | 14 | 19µs | $parameter->_get_behavior_values()->{minimum} = $minimum; # spent 19µs making 14 calls to Perl::Critic::PolicyParameter::_get_behavior_values, avg 1µs/call |
29 | 14 | 16µs | 14 | 15µs | $parameter->_get_behavior_values()->{maximum} = $maximum; # spent 15µs making 14 calls to Perl::Critic::PolicyParameter::_get_behavior_values, avg 1µs/call |
30 | |||||
31 | $parameter->_set_parser( | ||||
32 | # spent 418µs (213+204) within 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] which was called 14 times, avg 30µs/call:
# 14 times (213µs+204µs) by Perl::Critic::PolicyParameter::parse_and_validate_config_value at line 231 of Perl/Critic/PolicyParameter.pm, avg 30µs/call | ||||
33 | # Normally bad thing, obscuring a variable in a outer scope | ||||
34 | # with a variable with the same name is being done here in | ||||
35 | # order to remain consistent with the parser function interface. | ||||
36 | 14 | 5µs | my ($policy, $parameter, $config_string) = @_; ## no critic(Variables::ProhibitReusedNames) | ||
37 | |||||
38 | 14 | 18µs | 14 | 19µs | my $value_string = $parameter->get_default_string(); # spent 19µs making 14 calls to Perl::Critic::PolicyParameter::get_default_string, avg 1µs/call |
39 | |||||
40 | 14 | 3µs | if (defined $config_string) { | ||
41 | $value_string = $config_string; | ||||
42 | } | ||||
43 | |||||
44 | 14 | 700ns | my $value; | ||
45 | 14 | 4µs | if ( defined $value_string ) { | ||
46 | 14 | 59µs | 14 | 26µs | if ( # spent 26µs making 14 calls to Perl::Critic::PolicyParameter::Behavior::Integer::CORE:match, avg 2µs/call |
47 | $value_string !~ m/ \A [-+]? [1-9] [\d_]* \z /xms | ||||
48 | and $value_string ne '0' | ||||
49 | ) { | ||||
50 | $policy->throw_parameter_value_exception( | ||||
51 | $parameter->get_name(), | ||||
52 | $value_string, | ||||
53 | undef, | ||||
54 | 'does not look like an integer.', | ||||
55 | ); | ||||
56 | } | ||||
57 | |||||
58 | 14 | 8µs | $value_string =~ tr/_//d; | ||
59 | 14 | 11µs | $value = $value_string + 0; | ||
60 | |||||
61 | 14 | 3µs | if ( defined $minimum and $minimum > $value ) { | ||
62 | $policy->throw_parameter_value_exception( | ||||
63 | $parameter->get_name(), | ||||
64 | $value_string, | ||||
65 | undef, | ||||
66 | qq{is less than $minimum.}, | ||||
67 | ); | ||||
68 | } | ||||
69 | |||||
70 | 14 | 3µs | if ( defined $maximum and $maximum < $value ) { | ||
71 | $policy->throw_parameter_value_exception( | ||||
72 | $parameter->get_name(), | ||||
73 | $value_string, | ||||
74 | undef, | ||||
75 | qq{is greater than $maximum.}, | ||||
76 | ); | ||||
77 | } | ||||
78 | } | ||||
79 | |||||
80 | 14 | 53µs | 14 | 158µs | $policy->__set_parameter_value($parameter, $value); # spent 158µs making 14 calls to Perl::Critic::Policy::__set_parameter_value, avg 11µs/call |
81 | 14 | 29µs | return; | ||
82 | } | ||||
83 | 14 | 52µs | 14 | 26µs | ); # spent 26µs making 14 calls to Perl::Critic::PolicyParameter::_set_parser, avg 2µs/call |
84 | |||||
85 | 14 | 30µs | return; | ||
86 | } | ||||
87 | |||||
88 | #----------------------------------------------------------------------------- | ||||
89 | |||||
90 | sub generate_parameter_description { | ||||
91 | my ($self, $parameter) = @_; | ||||
92 | |||||
93 | my $minimum = $parameter->_get_behavior_values()->{minimum}; | ||||
94 | my $maximum = $parameter->_get_behavior_values()->{maximum}; | ||||
95 | |||||
96 | my $description = $parameter->_get_description_with_trailing_period(); | ||||
97 | if ( $description ) { | ||||
98 | $description .= qq{\n}; | ||||
99 | } | ||||
100 | |||||
101 | if (defined $minimum or defined $maximum) { | ||||
102 | if (defined $minimum) { | ||||
103 | $description .= "Minimum value $minimum. "; | ||||
104 | } else { | ||||
105 | $description .= 'No minimum. '; | ||||
106 | } | ||||
107 | |||||
108 | if (defined $maximum) { | ||||
109 | $description .= "Maximum value $maximum."; | ||||
110 | } else { | ||||
111 | $description .= 'No maximum.'; | ||||
112 | } | ||||
113 | } else { | ||||
114 | $description .= 'No limits.'; | ||||
115 | } | ||||
116 | |||||
117 | return $description; | ||||
118 | } | ||||
119 | |||||
120 | #----------------------------------------------------------------------------- | ||||
121 | |||||
122 | 1 | 2µs | 1; | ||
123 | |||||
124 | __END__ | ||||
# spent 26µs within Perl::Critic::PolicyParameter::Behavior::Integer::CORE:match which was called 14 times, avg 2µs/call:
# 14 times (26µ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 46, avg 2µs/call |