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

Filename/Users/timbo/perl5/perlbrew/perls/perl-5.18.2/lib/site_perl/5.18.2/Exception/Class.pm
StatementsExecuted 753 statements in 2.64ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
19112.11ms5.73msException::Class::::_make_subclassException::Class::_make_subclass (recurses: max depth 2, inclusive time 2.16ms)
1111.20ms4.06msException::Class::::BEGIN@7Exception::Class::BEGIN@7
212121455┬Ás6.07msException::Class::::importException::Class::import (recurses: max depth 2, inclusive time 2.30ms)
211121┬Ás21┬ÁsException::Class::::CORE:sortException::Class::CORE:sort (opcode)
11120┬Ás20┬ÁsException::Class::::BEGIN@3Exception::Class::BEGIN@3
191119┬Ás19┬ÁsException::Class::::CORE:substException::Class::CORE:subst (opcode)
1118┬Ás24┬ÁsException::Class::::BEGIN@5Exception::Class::BEGIN@5
1118┬Ás34┬ÁsException::Class::::BEGIN@8Exception::Class::BEGIN@8
1117┬Ás17┬ÁsException::Class::::BEGIN@165Exception::Class::BEGIN@165
1117┬Ás17┬ÁsException::Class::::BEGIN@43Exception::Class::BEGIN@43
1117┬Ás17┬ÁsException::Class::::BEGIN@76Exception::Class::BEGIN@76
1117┬Ás16┬ÁsException::Class::::BEGIN@173Exception::Class::BEGIN@173
1114┬Ás4┬ÁsException::Class::::BEGIN@11Exception::Class::BEGIN@11
2113┬Ás3┬ÁsException::Class::::CORE:substcontException::Class::CORE:substcont (opcode)
0000s0sException::Class::::ClassesException::Class::Classes
0000s0sException::Class::::__ANON__[:167]Exception::Class::__ANON__[:167]
0000s0sException::Class::::_make_parentsException::Class::_make_parents
0000s0sException::Class::::caughtException::Class::caught
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package Exception::Class;
21600ns$Exception::Class::VERSION = '1.38';
3250┬Ás120┬Ás
# spent 20┬Ás within Exception::Class::BEGIN@3 which was called: # once (20┬Ás+0s) by Perl::Critic::Exception::Fatal::Generic::BEGIN@20 at line 3
use 5.008001;
# spent 20┬Ás making 1 call to Exception::Class::BEGIN@3
4
5224┬Ás239┬Ás
# spent 24┬Ás (8+15) within Exception::Class::BEGIN@5 which was called: # once (8┬Ás+15┬Ás) by Perl::Critic::Exception::Fatal::Generic::BEGIN@20 at line 5
use strict;
# spent 24┬Ás making 1 call to Exception::Class::BEGIN@5 # spent 15┬Ás making 1 call to strict::import
6
72141┬Ás14.06ms
# spent 4.06ms (1.20+2.86) within Exception::Class::BEGIN@7 which was called: # once (1.20ms+2.86ms) by Perl::Critic::Exception::Fatal::Generic::BEGIN@20 at line 7
use Exception::Class::Base;
# spent 4.06ms making 1 call to Exception::Class::BEGIN@7
8232┬Ás258┬Ás
# spent 34┬Ás (8+25) within Exception::Class::BEGIN@8 which was called: # once (8┬Ás+25┬Ás) by Perl::Critic::Exception::Fatal::Generic::BEGIN@20 at line 8
use Scalar::Util qw(blessed);
# spent 34┬Ás making 1 call to Exception::Class::BEGIN@8 # spent 25┬Ás making 1 call to Exporter::import
9
1010sour $BASE_EXC_CLASS;
11198┬Ás14┬Ás
# spent 4┬Ás within Exception::Class::BEGIN@11 which was called: # once (4┬Ás+0s) by Perl::Critic::Exception::Fatal::Generic::BEGIN@20 at line 11
BEGIN { $BASE_EXC_CLASS ||= 'Exception::Class::Base'; }
# spent 4┬Ás making 1 call to Exception::Class::BEGIN@11
12
131200nsour %CLASSES;
14
15
# spent 6.07ms (455┬Ás+5.61) within Exception::Class::import which was called 21 times, avg 289┬Ás/call: # once (20┬Ás+1.15ms) by Perl::Critic::Exception::Configuration::Option::Policy::ParameterValue::BEGIN@22 at line 28 of Perl/Critic/Exception/Configuration/Option/Policy/ParameterValue.pm # once (18┬Ás+1.11ms) by Perl::Critic::Exception::Configuration::Option::Global::ParameterValue::BEGIN@22 at line 28 of Perl/Critic/Exception/Configuration/Option/Global/ParameterValue.pm # once (24┬Ás+1.06ms) by Perl::Critic::Exception::Fatal::Generic::BEGIN@20 at line 26 of Perl/Critic/Exception/Fatal/Generic.pm # once (21┬Ás+597┬Ás) by Perl::Critic::Exception::Configuration::Generic::BEGIN@20 at line 27 of Perl/Critic/Exception/Configuration/Generic.pm # once (32┬Ás+251┬Ás) by Perl::Critic::Exception::Configuration::Option::Policy::ExtraParameter::BEGIN@20 at line 26 of Perl/Critic/Exception/Configuration/Option/Policy/ExtraParameter.pm # once (25┬Ás+249┬Ás) by Perl::Critic::Exception::Configuration::NonExistentPolicy::BEGIN@20 at line 26 of Perl/Critic/Exception/Configuration/NonExistentPolicy.pm # once (31┬Ás+239┬Ás) by Perl::Critic::Exception::Fatal::Internal::BEGIN@20 at line 26 of Perl/Critic/Exception/Fatal/Internal.pm # once (19┬Ás+208┬Ás) by Perl::Critic::Exception::IO::BEGIN@24 at line 31 of Perl/Critic/Exception/IO.pm # once (25┬Ás+198┬Ás) by Perl::Critic::Exception::Fatal::PolicyDefinition::BEGIN@20 at line 26 of Perl/Critic/Exception/Fatal/PolicyDefinition.pm # once (20┬Ás+184┬Ás) by Perl::Critic::Exception::Parse::BEGIN@24 at line 31 of Perl/Critic/Exception/Parse.pm # once (17┬Ás+186┬Ás) by Perl::Critic::Exception::AggregateConfiguration::BEGIN@24 at line 31 of Perl/Critic/Exception/AggregateConfiguration.pm # once (28┬Ás+174┬Ás) by Perl::Critic::Exception::Configuration::Option::Global::ExtraParameter::BEGIN@20 at line 26 of Perl/Critic/Exception/Configuration/Option/Global/ExtraParameter.pm # once (21┬Ás+143┬Ás) by PPIx::Utilities::Exception::Bug::BEGIN@17 at line 22 of PPIx/Utilities/Exception/Bug.pm # once (10┬Ás+600ns) by Perl::Critic::PolicyFactory::BEGIN@37 at line 37 of Perl/Critic/PolicyFactory.pm # once (10┬Ás+500ns) by Perl::Critic::Policy::BEGIN@48 at line 48 of Perl/Critic/Policy.pm # once (24┬Ás+-24┬Ás) by Perl::Critic::Exception::BEGIN@18 at line 23 of Perl/Critic/Exception.pm # once (20┬Ás+-20┬Ás) by Perl::Critic::Exception::Fatal::BEGIN@18 at line 24 of Perl/Critic/Exception/Fatal.pm # once (18┬Ás+-18┬Ás) by Perl::Critic::Exception::Configuration::Option::Global::BEGIN@18 at line 23 of Perl/Critic/Exception/Configuration/Option/Global.pm # once (22┬Ás+-22┬Ás) by Perl::Critic::Exception::Configuration::Option::BEGIN@20 at line 26 of Perl/Critic/Exception/Configuration/Option.pm # once (32┬Ás+-32┬Ás) by Perl::Critic::Exception::Configuration::Option::Policy::BEGIN@20 at line 26 of Perl/Critic/Exception/Configuration/Option/Policy.pm # once (20┬Ás+-20┬Ás) by Perl::Critic::Exception::Configuration::BEGIN@18 at line 24 of Perl/Critic/Exception/Configuration.pm
sub import {
16218┬Ás my $class = shift;
17
182112┬Ás local $Exception::Class::Caller = caller();
19
20213┬Ás my %c;
21
2221800ns my %needs_parent;
232121┬Ás while ( my $subclass = shift ) {
241911┬Ás my $def = ref $_[0] ? shift : {};
251934┬Ás $def->{isa}
26 = $def->{isa}
27 ? ( ref $def->{isa} ? $def->{isa} : [ $def->{isa} ] )
28 : [];
29
301914┬Ás $c{$subclass} = $def;
31 }
32
33 # We need to sort by length because if we check for keys in the
34 # Foo::Bar:: stash, this creates a "Bar::" key in the Foo:: stash!
35MAKE_CLASSES:
3621112┬Ás2121┬Ás foreach my $subclass ( sort { length $a <=> length $b } keys %c ) {
# spent 21┬Ás making 21 calls to Exception::Class::CORE:sort, avg 1┬Ás/call
37197┬Ás my $def = $c{$subclass};
38
39 # We already made this one.
40196┬Ás next if $CLASSES{$subclass};
41
42 {
4321130┬Ás227┬Ás
# spent 17┬Ás (7+10) within Exception::Class::BEGIN@43 which was called: # once (7┬Ás+10┬Ás) by Perl::Critic::Exception::Fatal::Generic::BEGIN@20 at line 43
no strict 'refs';
# spent 17┬Ás making 1 call to Exception::Class::BEGIN@43 # spent 10┬Ás making 1 call to strict::unimport
441911┬Ás foreach my $parent ( @{ $def->{isa} } ) {
451940┬Ás unless ( keys %{"$parent\::"} ) {
46 $needs_parent{$subclass} = {
47 parents => $def->{isa},
48 def => $def
49 };
50 next MAKE_CLASSES;
51 }
52 }
53 }
54
55 $class->_make_subclass(
561957┬Ás195.73ms subclass => $subclass,
# spent 7.89ms making 19 calls to Exception::Class::_make_subclass, avg 415┬Ás/call, recursion: max depth 2, sum of overlapping time 2.16ms
57 def => $def || {},
58 );
59 }
60
6121110┬Ás foreach my $subclass ( keys %needs_parent ) {
62
63 # This will be used to spot circular references.
64 my %seen;
65 $class->_make_parents( \%needs_parent, $subclass, \%seen );
66 }
67}
68
69sub _make_parents {
70 my $class = shift;
71 my $needs = shift;
72 my $subclass = shift;
73 my $seen = shift;
74 my $child = shift; # Just for error messages.
75
762309┬Ás227┬Ás
# spent 17┬Ás (7+10) within Exception::Class::BEGIN@76 which was called: # once (7┬Ás+10┬Ás) by Perl::Critic::Exception::Fatal::Generic::BEGIN@20 at line 76
no strict 'refs';
# spent 17┬Ás making 1 call to Exception::Class::BEGIN@76 # spent 10┬Ás making 1 call to strict::unimport
77
78 # What if someone makes a typo in specifying their 'isa' param?
79 # This should catch it. Either it's been made because it didn't
80 # have missing parents OR it's in our hash as needing a parent.
81 # If neither of these is true then the _only_ place it is
82 # mentioned is in the 'isa' param for some other class, which is
83 # not a good enough reason to make a new class.
84 die
85 "Class $subclass appears to be a typo as it is only specified in the 'isa' param for $child\n"
86 unless exists $needs->{$subclass}
87 || $CLASSES{$subclass}
88 || keys %{"$subclass\::"};
89
90 foreach my $c ( @{ $needs->{$subclass}{parents} } ) {
91
92 # It's been made
93 next if $CLASSES{$c} || keys %{"$c\::"};
94
95 die "There appears to be some circularity involving $subclass\n"
96 if $seen->{$subclass};
97
98 $seen->{$subclass} = 1;
99
100 $class->_make_parents( $needs, $c, $seen, $subclass );
101 }
102
103 return if $CLASSES{$subclass} || keys %{"$subclass\::"};
104
105 $class->_make_subclass(
106 subclass => $subclass,
107 def => $needs->{$subclass}{def}
108 );
109}
110
111
# spent 5.73ms (2.11+3.62) within Exception::Class::_make_subclass which was called 19 times, avg 302┬Ás/call: # 19 times (2.11ms+3.62ms) by Exception::Class::import at line 56, avg 302┬Ás/call
sub _make_subclass {
112195┬Ás my $class = shift;
1131922┬Ás my %p = @_;
114
115195┬Ás my $subclass = $p{subclass};
116193┬Ás my $def = $p{def};
117
118191┬Ás my $isa;
1191927┬Ás if ( $def->{isa} ) {
120 $isa = ref $def->{isa} ? join ' ', @{ $def->{isa} } : $def->{isa};
121 }
122192┬Ás $isa ||= $BASE_EXC_CLASS;
123
124194┬Ás my $version_name = 'VERSION';
125
1261918┬Ás my $code = <<"EOPERL";
127package $subclass;
128
129use base qw($isa);
130
131our \$$version_name = '1.1';
132
1331;
134
135EOPERL
136
137196┬Ás if ( $def->{description} ) {
1381977┬Ás2122┬Ás ( my $desc = $def->{description} ) =~ s/([\\\'])/\\$1/g;
# spent 19┬Ás making 19 calls to Exception::Class::CORE:subst, avg 984ns/call # spent 3┬Ás making 2 calls to Exception::Class::CORE:substcont, avg 1┬Ás/call
1391917┬Ás $code .= <<"EOPERL";
140sub description
141{
142 return '$desc';
143}
144EOPERL
145 }
146
147193┬Ás my @fields;
148198┬Ás if ( my $fields = $def->{fields} ) {
149739┬Ás716┬Ás @fields = UNIVERSAL::isa( $fields, 'ARRAY' ) ? @$fields : $fields;
# spent 16┬Ás making 7 calls to UNIVERSAL::isa, avg 2┬Ás/call
150
151 $code
152 .= "sub Fields { return (\$_[0]->SUPER::Fields, "
153721┬Ás . join( ", ", map { "'$_'" } @fields )
154 . ") }\n\n";
155
15673┬Ás foreach my $field (@fields) {
1571019┬Ás $code .= sprintf( "sub %s { \$_[0]->{%s} }\n", $field, $field );
158 }
159 }
160
161199┬Ás if ( my $alias = $def->{alias} ) {
162112┬Ás die "Cannot make alias without caller"
163 unless defined $Exception::Class::Caller;
164
165274┬Ás227┬Ás
# spent 17┬Ás (7+10) within Exception::Class::BEGIN@165 which was called: # once (7┬Ás+10┬Ás) by Perl::Critic::Exception::Fatal::Generic::BEGIN@20 at line 165
no strict 'refs';
# spent 17┬Ás making 1 call to Exception::Class::BEGIN@165 # spent 10┬Ás making 1 call to strict::unimport
166 *{"$Exception::Class::Caller\::$alias"}
1671157┬Ás = sub { $subclass->throw(@_) };
168 }
169
170195┬Ás if ( my $defaults = $def->{defaults} ) {
171 $code
172 .= "sub _defaults { return shift->SUPER::_defaults, our \%_DEFAULTS }\n";
1732126┬Ás226┬Ás
# spent 16┬Ás (7+10) within Exception::Class::BEGIN@173 which was called: # once (7┬Ás+10┬Ás) by Perl::Critic::Exception::Fatal::Generic::BEGIN@20 at line 173
no strict 'refs';
# spent 16┬Ás making 1 call to Exception::Class::BEGIN@173 # spent 10┬Ás making 1 call to strict::unimport
174 *{"$subclass\::_DEFAULTS"} = {%$defaults};
175 }
176
17719757┬Ás eval $code;
# spent 2.46ms executing statements in string eval
# includes 5.34ms spent executing 851 calls to 4 subs defined therein. # spent 109┬Ás executing statements in string eval
# includes 17┬Ás spent executing 1 call to 4 subs defined therein. # spent 92┬Ás executing statements in string eval
# includes 9┬Ás spent executing 1 call to 6 subs defined therein. # spent 92┬Ás executing statements in string eval
# includes 9┬Ás spent executing 1 call to 5 subs defined therein. # spent 92┬Ás executing statements in string eval
# includes 12┬Ás spent executing 1 call to 4 subs defined therein. # spent 69┬Ás executing statements in string eval
# includes 10┬Ás spent executing 1 call to 4 subs defined therein. # spent 65┬Ás executing statements in string eval
# includes 10┬Ás spent executing 1 call to 4 subs defined therein. # spent 63┬Ás executing statements in string eval
# includes 15┬Ás spent executing 1 call to 2 subs defined therein. # spent 59┬Ás executing statements in string eval
# includes 15┬Ás spent executing 1 call to 2 subs defined therein. # spent 54┬Ás executing statements in string eval
# includes 12┬Ás spent executing 1 call to 2 subs defined therein. # spent 49┬Ás executing statements in string eval
# includes 12┬Ás spent executing 1 call to 2 subs defined therein. # spent 40┬Ás executing statements in string eval
# includes 11┬Ás spent executing 1 call to 2 subs defined therein. # spent 38┬Ás executing statements in string eval
# includes 10┬Ás spent executing 1 call to 2 subs defined therein. # spent 37┬Ás executing statements in string eval
# includes 10┬Ás spent executing 1 call to 2 subs defined therein. # spent 33┬Ás executing statements in string eval
# includes 10┬Ás spent executing 1 call to 2 subs defined therein. # spent 32┬Ás executing statements in string eval
# includes 9┬Ás spent executing 1 call to 2 subs defined therein. # spent 32┬Ás executing statements in string eval
# includes 9┬Ás spent executing 1 call to 2 subs defined therein. # spent 32┬Ás executing statements in string eval
# includes 10┬Ás spent executing 1 call to 2 subs defined therein. # spent 32┬Ás executing statements in string eval
# includes 10┬Ás spent executing 1 call to 2 subs defined therein.
178
179193┬Ás die $@ if $@;
180
1811992┬Ás $CLASSES{$subclass} = 1;
182}
183
184sub caught {
185 my $e = $@;
186
187 return $e unless $_[1];
188
189 return unless blessed($e) && $e->isa( $_[1] );
190 return $e;
191}
192
193sub Classes { sort keys %Exception::Class::CLASSES }
194
19512┬Ás1;
196
197# ABSTRACT: A module that allows you to declare real exception classes in Perl
198
199__END__
 
# spent 21┬Ás within Exception::Class::CORE:sort which was called 21 times, avg 1┬Ás/call: # 21 times (21┬Ás+0s) by Exception::Class::import at line 36, avg 1┬Ás/call
sub Exception::Class::CORE:sort; # opcode
# spent 19┬Ás within Exception::Class::CORE:subst which was called 19 times, avg 984ns/call: # 19 times (19┬Ás+0s) by Exception::Class::_make_subclass at line 138, avg 984ns/call
sub Exception::Class::CORE:subst; # opcode
# spent 3┬Ás within Exception::Class::CORE:substcont which was called 2 times, avg 1┬Ás/call: # 2 times (3┬Ás+0s) by Exception::Class::_make_subclass at line 138, avg 1┬Ás/call
sub Exception::Class::CORE:substcont; # opcode