← 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