Filename | /Users/timbo/perl5/perlbrew/perls/perl-5.18.2/lib/site_perl/5.18.2/Perl/Critic/PolicyFactory.pm |
Statements | Executed 4843 statements in 11.0ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
141 | 1 | 1 | 3.83ms | 347ms | _instantiate_policy | Perl::Critic::PolicyFactory::
141 | 1 | 1 | 2.16ms | 361ms | create_policy | Perl::Critic::PolicyFactory::
53 | 3 | 2 | 1.38ms | 2.15ms | site_policy_names | Perl::Critic::PolicyFactory::
1 | 1 | 1 | 1.38ms | 379ms | create_all_policies | Perl::Critic::PolicyFactory::
1 | 1 | 1 | 1.15ms | 5.46ms | BEGIN@27 | Perl::Critic::PolicyFactory::
282 | 2 | 1 | 994µs | 12.4ms | _handle_policy_instantiation_exception | Perl::Critic::PolicyFactory::
53 | 1 | 1 | 769µs | 769µs | CORE:sort (opcode) | Perl::Critic::PolicyFactory::
2 | 2 | 2 | 719µs | 1.30s | import | Perl::Critic::PolicyFactory::
1 | 1 | 1 | 330µs | 748µs | BEGIN@34 | Perl::Critic::PolicyFactory::
1 | 1 | 1 | 296µs | 718µs | BEGIN@33 | Perl::Critic::PolicyFactory::
142 | 2 | 1 | 204µs | 204µs | _profile | Perl::Critic::PolicyFactory::
1 | 1 | 1 | 54µs | 129µs | _validate_policies_in_profile | Perl::Critic::PolicyFactory::
1 | 1 | 1 | 39µs | 177µs | _init | Perl::Critic::PolicyFactory::
1 | 1 | 1 | 14µs | 14µs | BEGIN@10 | Perl::Critic::PolicyFactory::
1 | 1 | 1 | 14µs | 34µs | BEGIN@29 | Perl::Critic::PolicyFactory::
1 | 1 | 1 | 12µs | 30µs | BEGIN@28 | Perl::Critic::PolicyFactory::
1 | 1 | 1 | 11µs | 37µs | BEGIN@30 | Perl::Critic::PolicyFactory::
1 | 1 | 1 | 11µs | 188µs | new | Perl::Critic::PolicyFactory::
1 | 1 | 1 | 9µs | 144µs | BEGIN@35 | Perl::Critic::PolicyFactory::
1 | 1 | 1 | 9µs | 20µs | BEGIN@37 | Perl::Critic::PolicyFactory::
1 | 1 | 1 | 9µs | 35µs | BEGIN@31 | Perl::Critic::PolicyFactory::
1 | 1 | 1 | 7µs | 364µs | BEGIN@19 | Perl::Critic::PolicyFactory::
1 | 1 | 1 | 6µs | 10µs | BEGIN@12 | Perl::Critic::PolicyFactory::
1 | 1 | 1 | 6µs | 137µs | BEGIN@17 | Perl::Critic::PolicyFactory::
1 | 1 | 1 | 6µs | 17µs | BEGIN@11 | Perl::Critic::PolicyFactory::
1 | 1 | 1 | 6µs | 355µs | BEGIN@14 | Perl::Critic::PolicyFactory::
1 | 1 | 1 | 4µs | 4µs | BEGIN@16 | Perl::Critic::PolicyFactory::
0 | 0 | 0 | 0s | 0s | __ANON__[:87] | Perl::Critic::PolicyFactory::
0 | 0 | 0 | 0s | 0s | _module2path | Perl::Critic::PolicyFactory::
0 | 0 | 0 | 0s | 0s | _modules_from_blib | Perl::Critic::PolicyFactory::
0 | 0 | 0 | 0s | 0s | _was_loaded_from_blib | Perl::Critic::PolicyFactory::
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::PolicyFactory; | ||||
9 | |||||
10 | 2 | 35µs | 1 | 14µs | # spent 14µs within Perl::Critic::PolicyFactory::BEGIN@10 which was called:
# once (14µs+0s) by Perl::Critic::Config::BEGIN@24 at line 10 # spent 14µs making 1 call to Perl::Critic::PolicyFactory::BEGIN@10 |
11 | 2 | 17µs | 2 | 28µs | # spent 17µs (6+11) within Perl::Critic::PolicyFactory::BEGIN@11 which was called:
# once (6µs+11µs) by Perl::Critic::Config::BEGIN@24 at line 11 # spent 17µs making 1 call to Perl::Critic::PolicyFactory::BEGIN@11
# spent 11µs making 1 call to strict::import |
12 | 2 | 19µs | 2 | 14µs | # spent 10µs (6+4) within Perl::Critic::PolicyFactory::BEGIN@12 which was called:
# once (6µs+4µs) by Perl::Critic::Config::BEGIN@24 at line 12 # spent 10µs making 1 call to Perl::Critic::PolicyFactory::BEGIN@12
# spent 4µs making 1 call to warnings::import |
13 | |||||
14 | 2 | 22µs | 2 | 703µs | # spent 355µs (6+348) within Perl::Critic::PolicyFactory::BEGIN@14 which was called:
# once (6µs+348µs) by Perl::Critic::Config::BEGIN@24 at line 14 # spent 355µs making 1 call to Perl::Critic::PolicyFactory::BEGIN@14
# spent 348µs making 1 call to English::import |
15 | |||||
16 | 2 | 18µs | 1 | 4µs | # spent 4µs within Perl::Critic::PolicyFactory::BEGIN@16 which was called:
# once (4µs+0s) by Perl::Critic::Config::BEGIN@24 at line 16 # spent 4µs making 1 call to Perl::Critic::PolicyFactory::BEGIN@16 |
17 | 2 | 28µs | 2 | 268µs | # spent 137µs (6+131) within Perl::Critic::PolicyFactory::BEGIN@17 which was called:
# once (6µs+131µs) by Perl::Critic::Config::BEGIN@24 at line 17 # spent 137µs making 1 call to Perl::Critic::PolicyFactory::BEGIN@17
# spent 131µs making 1 call to Exporter::Tiny::import |
18 | |||||
19 | 1 | 200ns | # spent 364µs (7+357) within Perl::Critic::PolicyFactory::BEGIN@19 which was called:
# once (7µs+357µs) by Perl::Critic::Config::BEGIN@24 at line 26 | ||
20 | :characters | ||||
21 | $POLICY_NAMESPACE | ||||
22 | :data_conversion | ||||
23 | policy_long_name | ||||
24 | policy_short_name | ||||
25 | :internal_lookup | ||||
26 | 1 | 21µs | 2 | 720µs | }; # spent 364µs making 1 call to Perl::Critic::PolicyFactory::BEGIN@19
# spent 357µs making 1 call to Exporter::import |
27 | 2 | 108µs | 1 | 5.46ms | # spent 5.46ms (1.15+4.31) within Perl::Critic::PolicyFactory::BEGIN@27 which was called:
# once (1.15ms+4.31ms) by Perl::Critic::Config::BEGIN@24 at line 27 # spent 5.46ms making 1 call to Perl::Critic::PolicyFactory::BEGIN@27 |
28 | 2 | 33µs | 2 | 49µs | # spent 30µs (12+19) within Perl::Critic::PolicyFactory::BEGIN@28 which was called:
# once (12µs+19µs) by Perl::Critic::Config::BEGIN@24 at line 28 # spent 30µs making 1 call to Perl::Critic::PolicyFactory::BEGIN@28
# spent 19µs making 1 call to Exporter::import |
29 | 2 | 30µs | 2 | 54µs | # spent 34µs (14+20) within Perl::Critic::PolicyFactory::BEGIN@29 which was called:
# once (14µs+20µs) by Perl::Critic::Config::BEGIN@24 at line 29 # spent 34µs making 1 call to Perl::Critic::PolicyFactory::BEGIN@29
# spent 20µs making 1 call to Exporter::import |
30 | 2 | 36µs | 2 | 64µs | # spent 37µs (11+26) within Perl::Critic::PolicyFactory::BEGIN@30 which was called:
# once (11µs+26µs) by Perl::Critic::Config::BEGIN@24 at line 30 # spent 37µs making 1 call to Perl::Critic::PolicyFactory::BEGIN@30
# spent 26µs making 1 call to Exporter::import |
31 | 2 | 28µs | 2 | 60µs | # spent 35µs (9+26) within Perl::Critic::PolicyFactory::BEGIN@31 which was called:
# once (9µs+26µs) by Perl::Critic::Config::BEGIN@24 at line 31 # spent 35µs making 1 call to Perl::Critic::PolicyFactory::BEGIN@31
# spent 26µs making 1 call to Exporter::import |
32 | use Perl::Critic::Exception::Fatal::PolicyDefinition | ||||
33 | 2 | 129µs | 2 | 767µs | # spent 718µs (296+422) within Perl::Critic::PolicyFactory::BEGIN@33 which was called:
# once (296µs+422µs) by Perl::Critic::Config::BEGIN@24 at line 33 # spent 718µs making 1 call to Perl::Critic::PolicyFactory::BEGIN@33
# spent 50µs making 1 call to Exporter::import |
34 | 2 | 117µs | 1 | 748µs | # spent 748µs (330+418) within Perl::Critic::PolicyFactory::BEGIN@34 which was called:
# once (330µs+418µs) by Perl::Critic::Config::BEGIN@24 at line 34 # spent 748µs making 1 call to Perl::Critic::PolicyFactory::BEGIN@34 |
35 | 2 | 30µs | 2 | 280µs | # spent 144µs (9+135) within Perl::Critic::PolicyFactory::BEGIN@35 which was called:
# once (9µs+135µs) by Perl::Critic::Config::BEGIN@24 at line 35 # spent 144µs making 1 call to Perl::Critic::PolicyFactory::BEGIN@35
# spent 135µs making 1 call to Exporter::import |
36 | |||||
37 | 2 | 1.25ms | 2 | 31µs | # spent 20µs (9+11) within Perl::Critic::PolicyFactory::BEGIN@37 which was called:
# once (9µs+11µs) by Perl::Critic::Config::BEGIN@24 at line 37 # spent 20µs making 1 call to Perl::Critic::PolicyFactory::BEGIN@37
# spent 11µs making 1 call to Exception::Class::import |
38 | |||||
39 | 1 | 900ns | our $VERSION = '1.121'; | ||
40 | |||||
41 | #----------------------------------------------------------------------------- | ||||
42 | |||||
43 | # Globals. Ick! | ||||
44 | 1 | 700ns | my @site_policy_names = (); | ||
45 | |||||
46 | #----------------------------------------------------------------------------- | ||||
47 | |||||
48 | # Blech!!! This is ug-lee. Belongs in the constructor. And it shouldn't be | ||||
49 | # called "test" mode. | ||||
50 | # spent 1.30s (719µs+1.30) within Perl::Critic::PolicyFactory::import which was called 2 times, avg 652ms/call:
# once (714µs+1.30s) by Perl::Critic::Config::BEGIN@24 at line 24 of Perl/Critic/Config.pm
# once (6µs+0s) by Perl::Critic::Annotation::BEGIN@17 at line 17 of Perl/Critic/Annotation.pm | ||||
51 | |||||
52 | 2 | 2µs | my ( $class, %args ) = @_; | ||
53 | 2 | 2µs | my $test_mode = $args{-test}; | ||
54 | 2 | 700ns | my $extra_test_policies = $args{'-extra-test-policies'}; | ||
55 | |||||
56 | 2 | 1µs | if ( not @site_policy_names ) { | ||
57 | 1 | 600ns | my $eval_worked = eval { | ||
58 | 1 | 84µs | require Module::Pluggable; | ||
59 | 1 | 3µs | 1 | 38µs | Module::Pluggable->import(search_path => $POLICY_NAMESPACE, # spent 38µs making 1 call to Module::Pluggable::import |
60 | require => 1, inner => 0); | ||||
61 | 1 | 10µs | 1 | 1.29s | @site_policy_names = plugins(); #Exported by Module::Pluggable # spent 1.29s making 1 call to Module::Pluggable::__ANON__[Module/Pluggable.pm:32] |
62 | 1 | 800ns | 1; | ||
63 | }; | ||||
64 | |||||
65 | 1 | 300ns | if (not $eval_worked) { | ||
66 | if ( $EVAL_ERROR ) { | ||||
67 | throw_generic | ||||
68 | qq<Can't load Policies from namespace "$POLICY_NAMESPACE": $EVAL_ERROR>; | ||||
69 | } | ||||
70 | |||||
71 | throw_generic | ||||
72 | qq<Can't load Policies from namespace "$POLICY_NAMESPACE" for an unknown reason.>; | ||||
73 | } | ||||
74 | |||||
75 | 1 | 400ns | if ( not @site_policy_names ) { | ||
76 | throw_generic | ||||
77 | qq<No Policies found in namespace "$POLICY_NAMESPACE".>; | ||||
78 | } | ||||
79 | } | ||||
80 | |||||
81 | # In test mode, only load native policies, not third-party ones. So this | ||||
82 | # filters out any policy that was loaded from within a directory called | ||||
83 | # "blib". During the usual "./Build test" process this works fine, | ||||
84 | # but it doesn't work if you are using prove to test against the code | ||||
85 | # directly in the lib/ directory. | ||||
86 | |||||
87 | 2 | 600ns | if ( $test_mode && any {m/\b blib \b/xms} @INC ) { | ||
88 | @site_policy_names = _modules_from_blib( @site_policy_names ); | ||||
89 | |||||
90 | if ($extra_test_policies) { | ||||
91 | my @extra_policy_full_names = | ||||
92 | map { "${POLICY_NAMESPACE}::$_" } @{$extra_test_policies}; | ||||
93 | |||||
94 | push @site_policy_names, @extra_policy_full_names; | ||||
95 | } | ||||
96 | } | ||||
97 | |||||
98 | 2 | 9µs | return 1; | ||
99 | } | ||||
100 | |||||
101 | #----------------------------------------------------------------------------- | ||||
102 | # Some static helper subs | ||||
103 | |||||
104 | sub _modules_from_blib { | ||||
105 | my (@modules) = @_; | ||||
106 | return grep { _was_loaded_from_blib( _module2path($_) ) } @modules; | ||||
107 | } | ||||
108 | |||||
109 | sub _module2path { | ||||
110 | my $module = shift || return; | ||||
111 | return File::Spec::Unix->catdir(split m/::/xms, $module) . '.pm'; | ||||
112 | } | ||||
113 | |||||
114 | sub _was_loaded_from_blib { | ||||
115 | my $path = shift || return; | ||||
116 | my $full_path = $INC{$path}; | ||||
117 | return $full_path && $full_path =~ m/ (?: \A | \b b ) lib \b /xms; | ||||
118 | } | ||||
119 | |||||
120 | #----------------------------------------------------------------------------- | ||||
121 | |||||
122 | # spent 188µs (11+177) within Perl::Critic::PolicyFactory::new which was called:
# once (11µs+177µs) by Perl::Critic::Config::_init at line 137 of Perl/Critic/Config.pm | ||||
123 | |||||
124 | 1 | 2µs | my ( $class, %args ) = @_; | ||
125 | 1 | 2µs | my $self = bless {}, $class; | ||
126 | 1 | 3µs | 1 | 177µs | $self->_init( %args ); # spent 177µs making 1 call to Perl::Critic::PolicyFactory::_init |
127 | 1 | 3µs | return $self; | ||
128 | } | ||||
129 | |||||
130 | #----------------------------------------------------------------------------- | ||||
131 | |||||
132 | # spent 177µs (39+138) within Perl::Critic::PolicyFactory::_init which was called:
# once (39µs+138µs) by Perl::Critic::PolicyFactory::new at line 126 | ||||
133 | |||||
134 | 1 | 4µs | my ($self, %args) = @_; | ||
135 | |||||
136 | 1 | 900ns | my $profile = $args{-profile}; | ||
137 | 1 | 3µs | $self->{_profile} = $profile | ||
138 | or throw_internal q{The -profile argument is required}; | ||||
139 | |||||
140 | 1 | 600ns | my $incoming_errors = $args{-errors}; | ||
141 | 1 | 400ns | my $profile_strictness = $args{'-profile-strictness'}; | ||
142 | 1 | 200ns | $profile_strictness ||= $PROFILE_STRICTNESS_DEFAULT; | ||
143 | 1 | 700ns | $self->{_profile_strictness} = $profile_strictness; | ||
144 | |||||
145 | 1 | 3µs | 1 | 1µs | if ( $profile_strictness ne $PROFILE_STRICTNESS_QUIET ) { # spent 1µs making 1 call to Readonly::Scalar::FETCH |
146 | 1 | 100ns | my $errors; | ||
147 | |||||
148 | # If we're supposed to be strict or problems have already been found... | ||||
149 | 1 | 8µs | 3 | 7µs | if ( # spent 3µs making 1 call to Perl::Critic::Exception::AggregateConfiguration::exceptions
# spent 3µs making 1 call to Exception::Class::Base::__ANON__[Exception/Class/Base.pm:32]
# spent 1µs making 1 call to Readonly::Scalar::FETCH |
150 | $profile_strictness eq $PROFILE_STRICTNESS_FATAL | ||||
151 | or ( $incoming_errors and @{ $incoming_errors->exceptions() } ) | ||||
152 | ) { | ||||
153 | $errors = | ||||
154 | $incoming_errors | ||||
155 | ? $incoming_errors | ||||
156 | : Perl::Critic::Exception::AggregateConfiguration->new(); | ||||
157 | } | ||||
158 | |||||
159 | 1 | 2µs | 1 | 129µs | $self->_validate_policies_in_profile( $errors ); # spent 129µs making 1 call to Perl::Critic::PolicyFactory::_validate_policies_in_profile |
160 | |||||
161 | 1 | 2µs | 1 | 1µs | if ( # spent 1µs making 1 call to Exception::Class::Base::__ANON__[Exception/Class/Base.pm:32] |
162 | not $incoming_errors | ||||
163 | and $errors | ||||
164 | and $errors->has_exceptions() | ||||
165 | ) { | ||||
166 | $errors->rethrow(); | ||||
167 | } | ||||
168 | } | ||||
169 | |||||
170 | 1 | 4µs | return $self; | ||
171 | } | ||||
172 | |||||
173 | #----------------------------------------------------------------------------- | ||||
174 | |||||
175 | # spent 361ms (2.16+359) within Perl::Critic::PolicyFactory::create_policy which was called 141 times, avg 2.56ms/call:
# 141 times (2.16ms+359ms) by Perl::Critic::PolicyFactory::create_all_policies at line 220, avg 2.56ms/call | ||||
176 | |||||
177 | 141 | 121µs | my ($self, %args ) = @_; | ||
178 | |||||
179 | 141 | 70µs | my $policy_name = $args{-name} | ||
180 | or throw_internal q{The -name argument is required}; | ||||
181 | |||||
182 | # Normalize policy name to a fully-qualified package name | ||||
183 | 141 | 171µs | 141 | 1.73ms | $policy_name = policy_long_name( $policy_name ); # spent 1.73ms making 141 calls to Perl::Critic::Utils::policy_long_name, avg 12µs/call |
184 | 141 | 190µs | 141 | 1.56ms | my $policy_short_name = policy_short_name( $policy_name ); # spent 1.56ms making 141 calls to Perl::Critic::Utils::policy_short_name, avg 11µs/call |
185 | |||||
186 | |||||
187 | # Get the policy parameters from the user profile if they were | ||||
188 | # not given to us directly. If none exist, use an empty hash. | ||||
189 | 141 | 180µs | 141 | 201µs | my $profile = $self->_profile(); # spent 201µs making 141 calls to Perl::Critic::PolicyFactory::_profile, avg 1µs/call |
190 | 141 | 13µs | my $policy_config; | ||
191 | 141 | 60µs | if ( $args{-params} ) { | ||
192 | $policy_config = | ||||
193 | Perl::Critic::PolicyConfig->new( | ||||
194 | $policy_short_name, $args{-params} | ||||
195 | ); | ||||
196 | } | ||||
197 | else { | ||||
198 | 141 | 232µs | 141 | 8.91ms | $policy_config = $profile->policy_params($policy_name); # spent 8.91ms making 141 calls to Perl::Critic::UserProfile::policy_params, avg 63µs/call |
199 | 141 | 33µs | $policy_config ||= | ||
200 | Perl::Critic::PolicyConfig->new( $policy_short_name ); | ||||
201 | } | ||||
202 | |||||
203 | # Pull out base parameters. | ||||
204 | 141 | 459µs | 141 | 347ms | return $self->_instantiate_policy( $policy_name, $policy_config ); # spent 347ms making 141 calls to Perl::Critic::PolicyFactory::_instantiate_policy, avg 2.46ms/call |
205 | } | ||||
206 | |||||
207 | #----------------------------------------------------------------------------- | ||||
208 | |||||
209 | # spent 379ms (1.38+378) within Perl::Critic::PolicyFactory::create_all_policies which was called:
# once (1.38ms+378ms) by Perl::Critic::Config::_load_policies at line 219 of Perl/Critic/Config.pm | ||||
210 | |||||
211 | 1 | 400ns | my ( $self, $incoming_errors ) = @_; | ||
212 | |||||
213 | 1 | 2µs | 1 | 800ns | my $errors = # spent 800ns making 1 call to Exception::Class::Base::__ANON__[Exception/Class/Base.pm:32] |
214 | $incoming_errors | ||||
215 | ? $incoming_errors | ||||
216 | : Perl::Critic::Exception::AggregateConfiguration->new(); | ||||
217 | 1 | 200ns | my @policies; | ||
218 | |||||
219 | 1 | 12µs | 1 | 22µs | foreach my $name ( site_policy_names() ) { # spent 22µs making 1 call to Perl::Critic::PolicyFactory::site_policy_names |
220 | 282 | 301µs | 141 | 361ms | my $policy = eval { $self->create_policy( -name => $name ) }; # spent 361ms making 141 calls to Perl::Critic::PolicyFactory::create_policy, avg 2.56ms/call |
221 | |||||
222 | 141 | 151µs | 141 | 186µs | $errors->add_exception_or_rethrow( $EVAL_ERROR ); # spent 186µs making 141 calls to Perl::Critic::Exception::AggregateConfiguration::add_exception_or_rethrow, avg 1µs/call |
223 | |||||
224 | 141 | 421µs | 141 | 16.5ms | if ( $policy ) { # spent 16.5ms making 141 calls to Perl::Critic::Policy::to_string, avg 117µs/call |
225 | push @policies, $policy; | ||||
226 | } | ||||
227 | } | ||||
228 | |||||
229 | 1 | 3µs | 1 | 2µs | if ( not $incoming_errors and $errors->has_exceptions() ) { # spent 2µs making 1 call to Exception::Class::Base::__ANON__[Exception/Class/Base.pm:32] |
230 | $errors->rethrow(); | ||||
231 | } | ||||
232 | |||||
233 | 1 | 17µs | return @policies; | ||
234 | } | ||||
235 | |||||
236 | #----------------------------------------------------------------------------- | ||||
237 | |||||
238 | # spent 2.15ms (1.38+769µs) within Perl::Critic::PolicyFactory::site_policy_names which was called 53 times, avg 41µs/call:
# 51 times (1.34ms+748µs) by Perl::Critic::Annotation::_parse_annotation at line 255 of Perl/Critic/Annotation.pm, avg 41µs/call
# once (25µs+15µs) by Perl::Critic::PolicyFactory::_validate_policies_in_profile at line 305
# once (16µs+6µs) by Perl::Critic::PolicyFactory::create_all_policies at line 219 | ||||
239 | 53 | 1.45ms | 53 | 769µs | my @sorted_policy_names = sort @site_policy_names; # spent 769µs making 53 calls to Perl::Critic::PolicyFactory::CORE:sort, avg 15µs/call |
240 | 53 | 722µs | return @sorted_policy_names; | ||
241 | } | ||||
242 | |||||
243 | #----------------------------------------------------------------------------- | ||||
244 | |||||
245 | sub _profile { | ||||
246 | 142 | 29µs | my ($self) = @_; | ||
247 | |||||
248 | 142 | 312µs | return $self->{_profile}; | ||
249 | } | ||||
250 | |||||
251 | #----------------------------------------------------------------------------- | ||||
252 | |||||
253 | # This two-phase initialization is caused by the historical lack of a | ||||
254 | # requirement for Policies to invoke their super-constructor. | ||||
255 | # spent 347ms (3.83+343) within Perl::Critic::PolicyFactory::_instantiate_policy which was called 141 times, avg 2.46ms/call:
# 141 times (3.83ms+343ms) by Perl::Critic::PolicyFactory::create_policy at line 204, avg 2.46ms/call | ||||
256 | 141 | 44µs | my ($self, $policy_name, $policy_config) = @_; | ||
257 | |||||
258 | 141 | 135µs | 141 | 816µs | $policy_config->set_profile_strictness( $self->{_profile_strictness} ); # spent 816µs making 141 calls to Perl::Critic::PolicyConfig::set_profile_strictness, avg 6µs/call |
259 | |||||
260 | 282 | 1.32ms | 141 | 227ms | my $policy = eval { $policy_name->new( %{$policy_config} ) }; # spent 227ms making 141 calls to Perl::Critic::Policy::new, avg 1.61ms/call |
261 | 141 | 196µs | 141 | 12.1ms | _handle_policy_instantiation_exception( # spent 12.1ms making 141 calls to Perl::Critic::PolicyFactory::_handle_policy_instantiation_exception, avg 86µs/call |
262 | $policy_name, | ||||
263 | $policy, # Note: being used as a boolean here. | ||||
264 | $EVAL_ERROR, | ||||
265 | ); | ||||
266 | |||||
267 | 141 | 187µs | 141 | 447µs | $policy->__set_config( $policy_config ); # spent 447µs making 141 calls to Perl::Critic::Policy::__set_config, avg 3µs/call |
268 | |||||
269 | 423 | 589µs | 141 | 102ms | my $eval_worked = eval { $policy->__set_base_parameters(); 1; }; # spent 102ms making 141 calls to Perl::Critic::Policy::__set_base_parameters, avg 726µs/call |
270 | 141 | 182µs | 141 | 275µs | _handle_policy_instantiation_exception( # spent 275µs making 141 calls to Perl::Critic::PolicyFactory::_handle_policy_instantiation_exception, avg 2µs/call |
271 | $policy_name, $eval_worked, $EVAL_ERROR, | ||||
272 | ); | ||||
273 | |||||
274 | 141 | 286µs | return $policy; | ||
275 | } | ||||
276 | |||||
277 | # spent 12.4ms (994µs+11.4) within Perl::Critic::PolicyFactory::_handle_policy_instantiation_exception which was called 282 times, avg 44µs/call:
# 141 times (719µs+11.4ms) by Perl::Critic::PolicyFactory::_instantiate_policy at line 261, avg 86µs/call
# 141 times (275µs+0s) by Perl::Critic::PolicyFactory::_instantiate_policy at line 270, avg 2µs/call | ||||
278 | 282 | 125µs | my ($policy_name, $eval_worked, $eval_error) = @_; | ||
279 | |||||
280 | 282 | 316µs | 141 | 11.4ms | if (not $eval_worked) { # spent 11.4ms making 141 calls to Perl::Critic::Policy::to_string, avg 81µs/call |
281 | if ($eval_error) { | ||||
282 | my $exception = Exception::Class->caught(); | ||||
283 | |||||
284 | if (ref $exception) { | ||||
285 | $exception->rethrow(); | ||||
286 | } | ||||
287 | |||||
288 | throw_policy_definition | ||||
289 | qq<Unable to create policy "$policy_name": $eval_error>; | ||||
290 | } | ||||
291 | |||||
292 | throw_policy_definition | ||||
293 | qq<Unable to create policy "$policy_name" for an unknown reason.>; | ||||
294 | } | ||||
295 | |||||
296 | 282 | 566µs | return; | ||
297 | } | ||||
298 | |||||
299 | #----------------------------------------------------------------------------- | ||||
300 | |||||
301 | # spent 129µs (54+74) within Perl::Critic::PolicyFactory::_validate_policies_in_profile which was called:
# once (54µs+74µs) by Perl::Critic::PolicyFactory::_init at line 159 | ||||
302 | 1 | 400ns | my ($self, $errors) = @_; | ||
303 | |||||
304 | 1 | 2µs | 1 | 2µs | my $profile = $self->_profile(); # spent 2µs making 1 call to Perl::Critic::PolicyFactory::_profile |
305 | 1 | 34µs | 2 | 61µs | my %known_policies = hashify( $self->site_policy_names() ); # spent 39µs making 1 call to Perl::Critic::PolicyFactory::site_policy_names
# spent 22µs making 1 call to Perl::Critic::Utils::hashify |
306 | |||||
307 | 1 | 3µs | 1 | 11µs | for my $policy_name ( $profile->listed_policies() ) { # spent 11µs making 1 call to Perl::Critic::UserProfile::listed_policies |
308 | if ( not exists $known_policies{$policy_name} ) { | ||||
309 | my $message = qq{Policy "$policy_name" is not installed.}; | ||||
310 | |||||
311 | if ( $errors ) { | ||||
312 | $errors->add_exception( | ||||
313 | Perl::Critic::Exception::Configuration::NonExistentPolicy->new( | ||||
314 | policy => $policy_name, | ||||
315 | ) | ||||
316 | ); | ||||
317 | } | ||||
318 | else { | ||||
319 | warn qq{$message\n}; | ||||
320 | } | ||||
321 | } | ||||
322 | } | ||||
323 | |||||
324 | 1 | 7µs | return; | ||
325 | } | ||||
326 | |||||
327 | #----------------------------------------------------------------------------- | ||||
328 | |||||
329 | 1 | 4µs | 1; | ||
330 | |||||
331 | __END__ | ||||
# spent 769µs within Perl::Critic::PolicyFactory::CORE:sort which was called 53 times, avg 15µs/call:
# 53 times (769µs+0s) by Perl::Critic::PolicyFactory::site_policy_names at line 239, avg 15µs/call |