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

Filename/Users/timbo/perl5/perlbrew/perls/perl-5.18.2/lib/site_perl/5.18.2/Exception/Class/Base.pm
StatementsExecuted 11087 statements in 23.7ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
4241124.1ms253msException::Class::Base::::_initializeException::Class::Base::_initialize
424112.23ms255msException::Class::Base::::newException::Class::Base::new
1111.19ms2.12msException::Class::Base::::BEGIN@7Exception::Class::Base::BEGIN@7
42411520µs520µsException::Class::Base::::CORE:matchException::Class::Base::CORE:match (opcode)
42411334µs334µsException::Class::Base::::FieldsException::Class::Base::Fields
111265µs328µsException::Class::Base::::BEGIN@6Exception::Class::Base::BEGIN@6
11148µs48µsException::Class::Base::::BEGIN@35Exception::Class::Base::BEGIN@35
11141µs94µsException::Class::Base::::BEGIN@12Exception::Class::Base::BEGIN@12
11119µs26µsException::Class::Base::::BEGIN@4Exception::Class::Base::BEGIN@4
11116µs38µsException::Class::Base::::BEGIN@3Exception::Class::Base::BEGIN@3
11110µs87µsException::Class::Base::::BEGIN@10Exception::Class::Base::BEGIN@10
1119µs43µsException::Class::Base::::BEGIN@32Exception::Class::Base::BEGIN@32
1119µs35µsException::Class::Base::::BEGIN@8Exception::Class::Base::BEGIN@8
1118µs20µsException::Class::Base::::BEGIN@41Exception::Class::Base::BEGIN@41
1118µs18µsException::Class::Base::::BEGIN@61Exception::Class::Base::BEGIN@61
4417µs7µsException::Class::Base::::__ANON__[:32]Exception::Class::Base::__ANON__[:32]
0000s0sException::Class::Base::::ClassesException::Class::Base::Classes
0000s0sException::Class::Base::::__ANON__[:39]Exception::Class::Base::__ANON__[:39]
0000s0sException::Class::Base::::__ANON__[:60]Exception::Class::Base::__ANON__[:60]
0000s0sException::Class::Base::::as_stringException::Class::Base::as_string
0000s0sException::Class::Base::::caughtException::Class::Base::caught
0000s0sException::Class::Base::::context_hashException::Class::Base::context_hash
0000s0sException::Class::Base::::descriptionException::Class::Base::description
0000s0sException::Class::Base::::field_hashException::Class::Base::field_hash
0000s0sException::Class::Base::::full_messageException::Class::Base::full_message
0000s0sException::Class::Base::::rethrowException::Class::Base::rethrow
0000s0sException::Class::Base::::show_traceException::Class::Base::show_trace
0000s0sException::Class::Base::::throwException::Class::Base::throw
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::Base;
21700ns$Exception::Class::Base::VERSION = '1.38';
3227µs259µs
# spent 38µs (16+21) within Exception::Class::Base::BEGIN@3 which was called: # once (16µs+21µs) by Exception::Class::BEGIN@7 at line 3
use strict;
# spent 38µs making 1 call to Exception::Class::Base::BEGIN@3 # spent 21µs making 1 call to strict::import
4229µs232µs
# spent 26µs (19+6) within Exception::Class::Base::BEGIN@4 which was called: # once (19µs+6µs) by Exception::Class::BEGIN@7 at line 4
use warnings;
# spent 26µs making 1 call to Exception::Class::Base::BEGIN@4 # spent 6µs making 1 call to warnings::import
5
63119µs2338µs
# spent 328µs (265+62) within Exception::Class::Base::BEGIN@6 which was called: # once (265µs+62µs) by Exception::Class::BEGIN@7 at line 6
use Class::Data::Inheritable 0.02;
# spent 328µs making 1 call to Exception::Class::Base::BEGIN@6 # spent 10µs making 1 call to UNIVERSAL::VERSION
73119µs22.13ms
# spent 2.12ms (1.19+938µs) within Exception::Class::Base::BEGIN@7 which was called: # once (1.19ms+938µs) by Exception::Class::BEGIN@7 at line 7
use Devel::StackTrace 1.20;
# spent 2.12ms making 1 call to Exception::Class::Base::BEGIN@7 # spent 10µs making 1 call to UNIVERSAL::VERSION
8226µs261µs
# spent 35µs (9+26) within Exception::Class::Base::BEGIN@8 which was called: # once (9µs+26µs) by Exception::Class::BEGIN@7 at line 8
use Scalar::Util qw( blessed );
# spent 35µs making 1 call to Exception::Class::Base::BEGIN@8 # spent 26µs making 1 call to Exporter::import
9
10275µs2164µs
# spent 87µs (10+77) within Exception::Class::Base::BEGIN@10 which was called: # once (10µs+77µs) by Exception::Class::BEGIN@7 at line 10
use base qw(Class::Data::Inheritable);
# spent 87µs making 1 call to Exception::Class::Base::BEGIN@10 # spent 77µs making 1 call to base::import
11
12
# spent 94µs (41+54) within Exception::Class::Base::BEGIN@12 which was called: # once (41µs+54µs) by Exception::Class::BEGIN@7 at line 27
BEGIN {
1313µs111µs __PACKAGE__->mk_classdata('Trace');
# spent 11µs making 1 call to Class::Data::Inheritable::mk_classdata
1411µs18µs __PACKAGE__->mk_classdata('NoRefs');
# spent 8µs making 1 call to Class::Data::Inheritable::mk_classdata
1511µs13µs __PACKAGE__->NoRefs(1);
16
1711µs17µs __PACKAGE__->mk_classdata('NoContextInfo');
# spent 7µs making 1 call to Class::Data::Inheritable::mk_classdata
1811µs12µs __PACKAGE__->NoContextInfo(0);
19
2011µs111µs __PACKAGE__->mk_classdata('RespectOverload');
# spent 11µs making 1 call to Class::Data::Inheritable::mk_classdata
2111µs12µs __PACKAGE__->RespectOverload(0);
22
2311µs18µs __PACKAGE__->mk_classdata('MaxArgLength');
# spent 8µs making 1 call to Class::Data::Inheritable::mk_classdata
2415µs12µs __PACKAGE__->MaxArgLength(0);
25
264243.92ms
# spent 334µs within Exception::Class::Base::Fields which was called 424 times, avg 789ns/call: # 424 times (334µs+0s) by Perl::Critic::Exception::AggregateConfiguration::Fields at line 13 of (eval 46)[Exception/Class.pm:177], avg 789ns/call
sub Fields { () }
27134µs194µs}
# spent 94µs making 1 call to Exception::Class::Base::BEGIN@12
28
29use overload
30
31 # an exception is always true
32680µs277µs
# spent 43µs (9+34) within Exception::Class::Base::BEGIN@32 which was called: # once (9µs+34µs) by Exception::Class::BEGIN@7 at line 32 # spent 7µs within Exception::Class::Base::__ANON__[/Users/timbo/perl5/perlbrew/perls/perl-5.18.2/lib/site_perl/5.18.2/Exception/Class/Base.pm:32] which was called 4 times, avg 2µs/call: # once (3µs+0s) by Perl::Critic::PolicyFactory::_init at line 149 of Perl/Critic/PolicyFactory.pm # once (2µs+0s) by Perl::Critic::PolicyFactory::create_all_policies at line 229 of Perl/Critic/PolicyFactory.pm # once (1µs+0s) by Perl::Critic::PolicyFactory::_init at line 161 of Perl/Critic/PolicyFactory.pm # once (800ns+0s) by Perl::Critic::PolicyFactory::create_all_policies at line 213 of Perl/Critic/PolicyFactory.pm
bool => sub { 1 }, '""' => 'as_string', fallback => 1;
# spent 43µs making 1 call to Exception::Class::Base::BEGIN@32 # spent 34µs making 1 call to overload::import
33
34# Create accessor routines
35
# spent 48µs within Exception::Class::Base::BEGIN@35 which was called: # once (48µs+0s) by Exception::Class::BEGIN@7 at line 64
BEGIN {
3612µs my @fields = qw( message pid uid euid gid egid time trace );
37
381700ns foreach my $f (@fields) {
3989µs my $sub = sub { my $s = shift; return $s->{$f}; };
40
412109µs231µs
# spent 20µs (8+11) within Exception::Class::Base::BEGIN@41 which was called: # once (8µs+11µs) by Exception::Class::BEGIN@7 at line 41
no strict 'refs';
# spent 20µs making 1 call to Exception::Class::Base::BEGIN@41 # spent 11µs making 1 call to strict::unimport
42815µs *{$f} = $sub;
43 }
441500ns *error = \&message;
45
4612µs my %trace_fields = (
47 package => 'package',
48 file => 'filename',
49 line => 'line',
50 );
51
5219µs while ( my ( $f, $m ) = each %trace_fields ) {
53 my $sub = sub {
54 my $s = shift;
55 return $s->{$f} if exists $s->{$f};
56
57 my $frame = $s->trace->frame(0);
58
59 return $s->{$f} = $frame ? $frame->$m() : undef;
6034µs };
61230µs229µs
# spent 18µs (8+10) within Exception::Class::Base::BEGIN@61 which was called: # once (8µs+10µs) by Exception::Class::BEGIN@7 at line 61
no strict 'refs';
# spent 18µs making 1 call to Exception::Class::Base::BEGIN@61 # spent 10µs making 1 call to strict::unimport
6233µs *{$f} = $sub;
63 }
641679µs148µs}
# spent 48µs making 1 call to Exception::Class::Base::BEGIN@35
65
66sub Classes { Exception::Class::Classes() }
67
68sub throw {
69 my $proto = shift;
70
71 $proto->rethrow if ref $proto;
72
73 die $proto->new(@_);
74}
75
76sub rethrow {
77 my $self = shift;
78
79 die $self;
80}
81
82
# spent 255ms (2.23+253) within Exception::Class::Base::new which was called 424 times, avg 602µs/call: # 424 times (2.23ms+253ms) by Perl::Critic::Exception::AggregateConfiguration::new at line 47 of Perl/Critic/Exception/AggregateConfiguration.pm, avg 602µs/call
sub new {
8342493µs my $proto = shift;
8442488µs my $class = ref $proto || $proto;
85
86424501µs my $self = bless {}, $class;
87
88424480µs424253ms $self->_initialize(@_);
# spent 253ms making 424 calls to Exception::Class::Base::_initialize, avg 597µs/call
89
90424770µs return $self;
91}
92
93
# spent 253ms (24.1+229) within Exception::Class::Base::_initialize which was called 424 times, avg 597µs/call: # 424 times (24.1ms+229ms) by Exception::Class::Base::new at line 88, avg 597µs/call
sub _initialize {
9442446µs my $self = shift;
95424312µs my %p = @_ == 1 ? ( error => $_[0] ) : @_;
96
97424462µs $self->{message} = $p{message} || $p{error} || '';
98
9942489µs $self->{show_trace} = $p{show_trace} if exists $p{show_trace};
100
101424634µs424852µs if ( $self->NoContextInfo() ) {
# spent 852µs making 424 calls to Class::Data::Inheritable::__ANON__[Class/Data/Inheritable.pm:23], avg 2µs/call
102 $self->{show_trace} = 0;
103 $self->{package} = $self->{file} = $self->{line} = undef;
104 }
105 else {
106 # CORE::time is important to fix an error with some versions of
107 # Perl
108424372µs $self->{time} = CORE::time();
109424267µs $self->{pid} = $$;
110424479µs $self->{uid} = $<;
111424267µs $self->{euid} = $>;
1124241.57ms $self->{gid} = $(;
1134241.09ms $self->{egid} = $);
114
115424259µs my @ignore_class = (__PACKAGE__);
116424145µs my @ignore_package = 'Exception::Class';
117
118424163µs if ( my $i = delete $p{ignore_class} ) {
119 push @ignore_class, ( ref($i) eq 'ARRAY' ? @$i : $i );
120 }
121
12242453µs if ( my $i = delete $p{ignore_package} ) {
123 push @ignore_package, ( ref($i) eq 'ARRAY' ? @$i : $i );
124 }
125
1264242.52ms1696223ms $self->{trace} = Devel::StackTrace->new(
# spent 221ms making 424 calls to Devel::StackTrace::new, avg 520µs/call # spent 2.06ms making 1272 calls to Class::Data::Inheritable::__ANON__[Class/Data/Inheritable.pm:23], avg 2µs/call
127 ignore_class => \@ignore_class,
128 ignore_package => \@ignore_package,
129 no_refs => $self->NoRefs,
130 respect_overload => $self->RespectOverload,
131 max_arg_length => $self->MaxArgLength,
132 );
133 }
134
1354241.32ms4245.17ms my %fields = map { $_ => 1 } $self->Fields;
# spent 5.17ms making 424 calls to Perl::Critic::Exception::AggregateConfiguration::Fields, avg 12µs/call
1364241.51ms while ( my ( $key, $value ) = each %p ) {
1374244.60ms424520µs next if $key =~ /^(?:error|message|show_trace)$/;
# spent 520µs making 424 calls to Exception::Class::Base::CORE:match, avg 1µs/call
138
139424323µs if ( $fields{$key} ) {
140 $self->{$key} = $value;
141 }
142 else {
143 Exception::Class::Base->throw(
144 error => "unknown field $key passed to constructor for class "
145 . ref $self );
146 }
147 }
148}
149
150sub context_hash {
151 my $self = shift;
152
153 return {
154 time => $self->{time},
155 pid => $self->{pid},
156 uid => $self->{uid},
157 euid => $self->{euid},
158 gid => $self->{gid},
159 egid => $self->{egid},
160 };
161}
162
163sub field_hash {
164 my $self = shift;
165
166 my $hash = {};
167
168 for my $field ( $self->Fields ) {
169 $hash->{$field} = $self->$field;
170 }
171
172 return $hash;
173}
174
175sub description {
176 return 'Generic exception';
177}
178
179sub show_trace {
180 my $self = shift;
181
182 return 0 unless $self->{trace};
183
184 if (@_) {
185 $self->{show_trace} = shift;
186 }
187
188 return exists $self->{show_trace} ? $self->{show_trace} : $self->Trace;
189}
190
191sub as_string {
192 my $self = shift;
193
194 my $str = $self->full_message;
195 unless ( defined $str && length $str ) {
196 my $desc = $self->description;
197 $str = defined $desc
198 && length $desc ? "[$desc]" : "[Generic exception]";
199 }
200
201 $str .= "\n\n" . $self->trace->as_string
202 if $self->show_trace;
203
204 return $str;
205}
206
207sub full_message { $_[0]->{message} }
208
209#
210# The %seen bit protects against circular inheritance.
211#
2121900nseval <<'EOF' if $] == 5.006;
213sub isa {
214 my ( $inheritor, $base ) = @_;
215 $inheritor = ref($inheritor) if ref($inheritor);
216
217 my %seen;
218
219 no strict 'refs';
220 my @parents = ( $inheritor, @{"$inheritor\::ISA"} );
221 while ( my $class = shift @parents ) {
222 return 1 if $class eq $base;
223
224 push @parents, grep { !$seen{$_}++ } @{"$class\::ISA"};
225 }
226 return 0;
227}
228EOF
229
230sub caught {
231 my $class = shift;
232
233 my $e = $@;
234
235 return unless defined $e && blessed($e) && $e->isa($class);
236 return $e;
237}
238
23918µs1;
240
241# ABSTRACT: A base class for exception objects
242
243__END__
 
# spent 520µs within Exception::Class::Base::CORE:match which was called 424 times, avg 1µs/call: # 424 times (520µs+0s) by Exception::Class::Base::_initialize at line 137, avg 1µs/call
sub Exception::Class::Base::CORE:match; # opcode