← 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:13 2016

Filename/Users/timbo/perl5/perlbrew/perls/perl-5.18.2/lib/site_perl/5.18.2/Perl/Critic/Theme.pm
StatementsExecuted 620 statements in 1.62ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
14111923µs11.9msPerl::Critic::Theme::::policy_is_thematicPerl::Critic::Theme::policy_is_thematic
22236µs39µsPerl::Critic::Theme::::cook_rulePerl::Critic::Theme::cook_rule
11123µs41µsPerl::Critic::Theme::::_initPerl::Critic::Theme::_init
11115µs15µsPerl::Critic::Theme::::BEGIN@10Perl::Critic::Theme::BEGIN@10
11113µs92µsPerl::Critic::Theme::::BEGIN@23Perl::Critic::Theme::BEGIN@23
11112µs73µsPerl::Critic::Theme::::BEGIN@21Perl::Critic::Theme::BEGIN@21
11111µs52µsPerl::Critic::Theme::::newPerl::Critic::Theme::new
11110µs174µsPerl::Critic::Theme::::BEGIN@18Perl::Critic::Theme::BEGIN@18
1119µs376µsPerl::Critic::Theme::::BEGIN@13Perl::Critic::Theme::BEGIN@13
1118µs13µsPerl::Critic::Theme::::BEGIN@16Perl::Critic::Theme::BEGIN@16
1117µs26µsPerl::Critic::Theme::::BEGIN@14Perl::Critic::Theme::BEGIN@14
1117µs293µsPerl::Critic::Theme::::BEGIN@20Perl::Critic::Theme::BEGIN@20
1117µs18µsPerl::Critic::Theme::::BEGIN@11Perl::Critic::Theme::BEGIN@11
1116µs11µsPerl::Critic::Theme::::BEGIN@12Perl::Critic::Theme::BEGIN@12
1114µs5µsPerl::Critic::Theme::::CORE:regcompPerl::Critic::Theme::CORE:regcomp (opcode)
14713µs3µsPerl::Critic::Theme::::CORE:substPerl::Critic::Theme::CORE:subst (opcode)
1111µs1µsPerl::Critic::Theme::::CORE:qrPerl::Critic::Theme::CORE:qr (opcode)
111300ns300nsPerl::Critic::Theme::::CORE:matchPerl::Critic::Theme::CORE:match (opcode)
0000s0sPerl::Critic::Theme::::rulePerl::Critic::Theme::rule
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::Theme;
9
10238µs115µs
# spent 15µs within Perl::Critic::Theme::BEGIN@10 which was called: # once (15µs+0s) by Perl::Critic::Config::BEGIN@25 at line 10
use 5.006001;
# spent 15µs making 1 call to Perl::Critic::Theme::BEGIN@10
11219µs230µs
# spent 18µs (7+11) within Perl::Critic::Theme::BEGIN@11 which was called: # once (7µs+11µs) by Perl::Critic::Config::BEGIN@25 at line 11
use strict;
# spent 18µs making 1 call to Perl::Critic::Theme::BEGIN@11 # spent 11µs making 1 call to strict::import
12219µs216µs
# spent 11µs (6+5) within Perl::Critic::Theme::BEGIN@12 which was called: # once (6µs+5µs) by Perl::Critic::Config::BEGIN@25 at line 12
use warnings;
# spent 11µs making 1 call to Perl::Critic::Theme::BEGIN@12 # spent 5µs making 1 call to warnings::import
13224µs2743µs
# spent 376µs (9+367) within Perl::Critic::Theme::BEGIN@13 which was called: # once (9µs+367µs) by Perl::Critic::Config::BEGIN@25 at line 13
use English qw(-no_match_vars);
# spent 376µs making 1 call to Perl::Critic::Theme::BEGIN@13 # spent 367µs making 1 call to English::import
14221µs245µs
# spent 26µs (7+19) within Perl::Critic::Theme::BEGIN@14 which was called: # once (7µs+19µs) by Perl::Critic::Config::BEGIN@25 at line 14
use Readonly;
# spent 26µs making 1 call to Perl::Critic::Theme::BEGIN@14 # spent 19µs making 1 call to Exporter::import
15
16220µs218µs
# spent 13µs (8+5) within Perl::Critic::Theme::BEGIN@16 which was called: # once (8µs+5µs) by Perl::Critic::Config::BEGIN@25 at line 16
use Exporter 'import';
# spent 13µs making 1 call to Perl::Critic::Theme::BEGIN@16 # spent 5µs making 1 call to Exporter::import
17
18227µs2339µs
# spent 174µs (10+164) within Perl::Critic::Theme::BEGIN@18 which was called: # once (10µs+164µs) by Perl::Critic::Config::BEGIN@25 at line 18
use List::MoreUtils qw(any);
# spent 174µs making 1 call to Perl::Critic::Theme::BEGIN@18 # spent 164µs making 1 call to Exporter::Tiny::import
19
20223µs2579µs
# spent 293µs (7+286) within Perl::Critic::Theme::BEGIN@20 which was called: # once (7µs+286µs) by Perl::Critic::Config::BEGIN@25 at line 20
use Perl::Critic::Utils qw{ :characters :data_conversion };
# spent 293µs making 1 call to Perl::Critic::Theme::BEGIN@20 # spent 286µs making 1 call to Exporter::import
21228µs2134µs
# spent 73µs (12+61) within Perl::Critic::Theme::BEGIN@21 which was called: # once (12µs+61µs) by Perl::Critic::Config::BEGIN@25 at line 21
use Perl::Critic::Exception::Fatal::Internal qw{ &throw_internal };
# spent 73µs making 1 call to Perl::Critic::Theme::BEGIN@21 # spent 61µs making 1 call to Exporter::import
22use Perl::Critic::Exception::Configuration::Option::Global::ParameterValue
232466µs2170µs
# spent 92µs (13+78) within Perl::Critic::Theme::BEGIN@23 which was called: # once (13µs+78µs) by Perl::Critic::Config::BEGIN@25 at line 23
qw{ &throw_global_value };
# spent 92µs making 1 call to Perl::Critic::Theme::BEGIN@23 # spent 78µs making 1 call to Exporter::import
24
25#-----------------------------------------------------------------------------
26
271700nsour $VERSION = '1.121';
28
29#-----------------------------------------------------------------------------
30
3112µs126µsReadonly::Array our @EXPORT_OK => qw{
# spent 26µs making 1 call to Readonly::Array
32 $RULE_INVALID_CHARACTER_REGEX
33 cook_rule
34};
35
36#-----------------------------------------------------------------------------
37
3816µs226µsReadonly::Scalar our $RULE_INVALID_CHARACTER_REGEX =>
# spent 24µs making 1 call to Readonly::Scalar # spent 1µs making 1 call to Perl::Critic::Theme::CORE:qr
39 qr/ ( [^()\s\w\d+\-*&|!] ) /xms;
40
41#-----------------------------------------------------------------------------
42
431800ns120µsReadonly::Scalar my $CONFIG_KEY => 'theme';
# spent 20µs making 1 call to Readonly::Scalar
44
45#-----------------------------------------------------------------------------
46
47
# spent 52µs (11+41) within Perl::Critic::Theme::new which was called: # once (11µs+41µs) by Perl::Critic::Config::_validate_and_save_theme at line 659 of Perl/Critic/Config.pm
sub new {
48
4912µs my ( $class, %args ) = @_;
5012µs my $self = bless {}, $class;
5113µs141µs $self->_init( %args );
# spent 41µs making 1 call to Perl::Critic::Theme::_init
5214µs return $self;
53}
54
55#-----------------------------------------------------------------------------
56
57
# spent 41µs (23+18) within Perl::Critic::Theme::_init which was called: # once (23µs+18µs) by Perl::Critic::Theme::new at line 51
sub _init {
58
5911µs my ($self, %args) = @_;
6013µs11µs my $rule = $args{-rule} || $EMPTY;
# spent 1µs making 1 call to Readonly::Scalar::FETCH
61
62110µs37µs if ( $rule =~ m/$RULE_INVALID_CHARACTER_REGEX/xms ) {
# spent 5µs making 1 call to Perl::Critic::Theme::CORE:regcomp # spent 1µs making 1 call to Readonly::Scalar::FETCH # spent 300ns making 1 call to Perl::Critic::Theme::CORE:match
63 throw_global_value
64 option_name => $CONFIG_KEY,
65 option_value => $rule,
66 message_suffix => qq{contains an invalid character: "$1".};
67 }
68
6915µs111µs $self->{_rule} = cook_rule( $rule );
# spent 11µs making 1 call to Perl::Critic::Theme::cook_rule
70
7114µs return $self;
72}
73
74#-----------------------------------------------------------------------------
75
76sub rule {
77 my $self = shift;
78 return $self->{_rule};
79}
80
81#-----------------------------------------------------------------------------
82
83
# spent 11.9ms (923µs+11.0) within Perl::Critic::Theme::policy_is_thematic which was called 141 times, avg 85µs/call: # 141 times (923µs+11.0ms) by Perl::Critic::Config::_policy_is_thematic at line 281 of Perl/Critic/Config.pm, avg 85µs/call
sub policy_is_thematic {
84
8514198µs my ($self, %args) = @_;
86141332µs14111.0ms my $policy = $args{-policy}
# spent 11.0ms making 141 calls to Perl::Critic::Policy::to_string, avg 78µs/call
87 || throw_internal 'The -policy argument is required';
8814139µs ref $policy
89 || throw_internal 'The -policy must be an object';
90
91141381µs my $rule = $self->{_rule} or return 1;
92 my %themes = hashify( $policy->get_themes() );
93
94 # This bit of magic turns the rule into a perl expression that can be
95 # eval-ed for truth. Each theme name in the rule is translated to 1 or 0
96 # if the $policy belongs in that theme. For example:
97 #
98 # 'bugs && (pbp || core)' ...could become... '1 && (0 || 1)'
99
100 my $as_code = $rule; #Making a copy, so $rule is preserved
101 $as_code =~ s/ ( [\w\d]+ ) /exists $themes{$1} || 0/gexms;
102 my $is_thematic = eval $as_code; ## no critic (ProhibitStringyEval)
103
104 if ($EVAL_ERROR) {
105 throw_global_value
106 option_name => $CONFIG_KEY,
107 option_value => $rule,
108 message_suffix => q{contains a syntax error.};
109 }
110
111 return $is_thematic;
112}
113
114#-----------------------------------------------------------------------------
115
116
# spent 39µs (36+3) within Perl::Critic::Theme::cook_rule which was called 2 times, avg 19µs/call: # once (26µs+2µs) by Perl::Critic::Config::_validate_and_save_theme at line 640 of Perl/Critic/Config.pm # once (10µs+900ns) by Perl::Critic::Theme::_init at line 69
sub cook_rule {
1172700ns my ($raw_rule) = @_;
1182400ns return if not defined $raw_rule;
119
120 #Translate logical operators
12127µs2800ns $raw_rule =~ s{\b not \b}{!}ixmsg; # "not" -> "!"
# spent 800ns making 2 calls to Perl::Critic::Theme::CORE:subst, avg 400ns/call
12227µs2300ns $raw_rule =~ s{\b and \b}{&&}ixmsg; # "and" -> "&&"
# spent 300ns making 2 calls to Perl::Critic::Theme::CORE:subst, avg 150ns/call
12324µs2400ns $raw_rule =~ s{\b or \b}{||}ixmsg; # "or" -> "||"
# spent 400ns making 2 calls to Perl::Critic::Theme::CORE:subst, avg 200ns/call
124
125 #Translate algebra operators (for backward compatibility)
12623µs2400ns $raw_rule =~ s{\A [-] }{!}ixmsg; # "-" -> "!" e.g. difference
# spent 400ns making 2 calls to Perl::Critic::Theme::CORE:subst, avg 200ns/call
12723µs2400ns $raw_rule =~ s{ [-] }{&& !}ixmsg; # "-" -> "&& !" e.g. difference
# spent 400ns making 2 calls to Perl::Critic::Theme::CORE:subst, avg 200ns/call
12823µs2300ns $raw_rule =~ s{ [*] }{&&}ixmsg; # "*" -> "&&" e.g. intersection
# spent 300ns making 2 calls to Perl::Critic::Theme::CORE:subst, avg 150ns/call
12924µs2400ns $raw_rule =~ s{ [+] }{||}ixmsg; # "+" -> "||" e.g. union
# spent 400ns making 2 calls to Perl::Critic::Theme::CORE:subst, avg 200ns/call
130
13121µs my $cooked_rule = lc $raw_rule; #Is now cooked!
13226µs return $cooked_rule;
133}
134
135
13614µs1;
137
138__END__
 
# spent 300ns within Perl::Critic::Theme::CORE:match which was called: # once (300ns+0s) by Perl::Critic::Theme::_init at line 62
sub Perl::Critic::Theme::CORE:match; # opcode
# spent 1µs within Perl::Critic::Theme::CORE:qr which was called: # once (1µs+0s) by Perl::Critic::Config::BEGIN@25 at line 38
sub Perl::Critic::Theme::CORE:qr; # opcode
# spent 5µs (4+1000ns) within Perl::Critic::Theme::CORE:regcomp which was called: # once (4µs+1000ns) by Perl::Critic::Theme::_init at line 62
sub Perl::Critic::Theme::CORE:regcomp; # opcode
# spent 3µs within Perl::Critic::Theme::CORE:subst which was called 14 times, avg 214ns/call: # 2 times (800ns+0s) by Perl::Critic::Theme::cook_rule at line 121, avg 400ns/call # 2 times (400ns+0s) by Perl::Critic::Theme::cook_rule at line 127, avg 200ns/call # 2 times (400ns+0s) by Perl::Critic::Theme::cook_rule at line 126, avg 200ns/call # 2 times (400ns+0s) by Perl::Critic::Theme::cook_rule at line 123, avg 200ns/call # 2 times (400ns+0s) by Perl::Critic::Theme::cook_rule at line 129, avg 200ns/call # 2 times (300ns+0s) by Perl::Critic::Theme::cook_rule at line 122, avg 150ns/call # 2 times (300ns+0s) by Perl::Critic::Theme::cook_rule at line 128, avg 150ns/call
sub Perl::Critic::Theme::CORE:subst; # opcode