← Index
NYTProf Performance Profile   « line view »
For bin/benchmark-perlformance
  Run on Fri Apr 17 15:31:48 2015
Reported on Fri Apr 17 15:32:02 2015

Filename/home/ss5/perl5/perlbrew/perls/tapper-perl/lib/site_perl/5.16.3/Exception/Class/Base.pm
StatementsExecuted 394 statements in 1.98ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
111887µs3.29msException::Class::Base::::BEGIN@10Exception::Class::Base::BEGIN@10
811417µs3.52msException::Class::Base::::_initializeException::Class::Base::_initialize
111191µs244µsException::Class::Base::::BEGIN@9Exception::Class::Base::BEGIN@9
811189µs3.71msException::Class::Base::::newException::Class::Base::new
3421187µs226µsException::Class::Base::::caughtException::Class::Base::caught
81173µs3.78msException::Class::Base::::throwException::Class::Base::throw
11138µs78µsException::Class::Base::::BEGIN@15Exception::Class::Base::BEGIN@15
11133µs33µsException::Class::Base::::BEGIN@38Exception::Class::Base::BEGIN@38
11117µs29µsException::Class::Base::::BEGIN@6Exception::Class::Base::BEGIN@6
81112µs12µsException::Class::Base::::FieldsException::Class::Base::Fields
81111µs11µsException::Class::Base::::__ANON__[:35]Exception::Class::Base::__ANON__[:35]
1119µs17µsException::Class::Base::::BEGIN@64Exception::Class::Base::BEGIN@64
1117µs11µsException::Class::Base::::BEGIN@7Exception::Class::Base::BEGIN@7
1117µs28µsException::Class::Base::::BEGIN@11Exception::Class::Base::BEGIN@11
1117µs62µsException::Class::Base::::BEGIN@13Exception::Class::Base::BEGIN@13
1117µs40µsException::Class::Base::::BEGIN@35Exception::Class::Base::BEGIN@35
1117µs16µsException::Class::Base::::BEGIN@44Exception::Class::Base::BEGIN@44
0000s0sException::Class::Base::::ClassesException::Class::Base::Classes
0000s0sException::Class::Base::::__ANON__[:42]Exception::Class::Base::__ANON__[:42]
0000s0sException::Class::Base::::__ANON__[:63]Exception::Class::Base::__ANON__[:63]
0000s0sException::Class::Base::::as_stringException::Class::Base::as_string
0000s0sException::Class::Base::::descriptionException::Class::Base::description
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
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;
2{
322µs $Exception::Class::Base::VERSION = '1.37';
4}
5
6222µs240µs
# spent 29µs (17+12) within Exception::Class::Base::BEGIN@6 which was called: # once (17µs+12µs) by Exception::Class::BEGIN@10 at line 6
use strict;
# spent 29µs making 1 call to Exception::Class::Base::BEGIN@6 # spent 12µs making 1 call to strict::import
7220µs214µs
# spent 11µs (7+3) within Exception::Class::Base::BEGIN@7 which was called: # once (7µs+3µs) by Exception::Class::BEGIN@10 at line 7
use warnings;
# spent 11µs making 1 call to Exception::Class::Base::BEGIN@7 # spent 3µs making 1 call to warnings::import
8
9396µs2253µs
# spent 244µs (191+52) within Exception::Class::Base::BEGIN@9 which was called: # once (191µs+52µs) by Exception::Class::BEGIN@10 at line 9
use Class::Data::Inheritable 0.02;
# spent 244µs making 1 call to Exception::Class::Base::BEGIN@9 # spent 9µs making 1 call to UNIVERSAL::VERSION
10393µs23.30ms
# spent 3.29ms (887µs+2.40) within Exception::Class::Base::BEGIN@10 which was called: # once (887µs+2.40ms) by Exception::Class::BEGIN@10 at line 10
use Devel::StackTrace 1.20;
# spent 3.29ms making 1 call to Exception::Class::Base::BEGIN@10 # spent 9µs making 1 call to UNIVERSAL::VERSION
11221µs248µs
# spent 28µs (7+21) within Exception::Class::Base::BEGIN@11 which was called: # once (7µs+21µs) by Exception::Class::BEGIN@10 at line 11
use Scalar::Util qw( blessed );
# spent 28µs making 1 call to Exception::Class::Base::BEGIN@11 # spent 21µs making 1 call to Exporter::import
12
13255µs2116µs
# spent 62µs (7+54) within Exception::Class::Base::BEGIN@13 which was called: # once (7µs+54µs) by Exception::Class::BEGIN@10 at line 13
use base qw(Class::Data::Inheritable);
# spent 62µs making 1 call to Exception::Class::Base::BEGIN@13 # spent 54µs making 1 call to base::import
14
15
# spent 78µs (38+40) within Exception::Class::Base::BEGIN@15 which was called: # once (38µs+40µs) by Exception::Class::BEGIN@10 at line 30
BEGIN {
1614µs18µs __PACKAGE__->mk_classdata('Trace');
# spent 8µs making 1 call to Class::Data::Inheritable::mk_classdata
1712µs16µs __PACKAGE__->mk_classdata('NoRefs');
# spent 6µs making 1 call to Class::Data::Inheritable::mk_classdata
1812µs12µs __PACKAGE__->NoRefs(1);
19
2011µs16µs __PACKAGE__->mk_classdata('NoContextInfo');
# spent 6µs making 1 call to Class::Data::Inheritable::mk_classdata
2112µs12µs __PACKAGE__->NoContextInfo(0);
22
2311µs16µs __PACKAGE__->mk_classdata('RespectOverload');
# spent 6µs making 1 call to Class::Data::Inheritable::mk_classdata
2412µs12µs __PACKAGE__->RespectOverload(0);
25
2611µs16µs __PACKAGE__->mk_classdata('MaxArgLength');
# spent 6µs making 1 call to Class::Data::Inheritable::mk_classdata
2714µs12µs __PACKAGE__->MaxArgLength(0);
28
29824µs
# spent 12µs within Exception::Class::Base::Fields which was called 8 times, avg 1µs/call: # 8 times (12µs+0s) by Exception::Class::Base::_initialize at line 140, avg 1µs/call
sub Fields { () }
30127µs178µs}
# spent 78µs making 1 call to Exception::Class::Base::BEGIN@15
31
32use overload
33
34 # an exception is always true
351080µs273µs
# spent 11µs within Exception::Class::Base::__ANON__[/home/ss5/perl5/perlbrew/perls/tapper-perl/lib/site_perl/5.16.3/Exception/Class/Base.pm:35] which was called 8 times, avg 1µs/call: # 8 times (11µs+0s) by Iterator::value at line 229 of Iterator.pm, avg 1µs/call # spent 40µs (7+33) within Exception::Class::Base::BEGIN@35 which was called: # once (7µs+33µs) by Exception::Class::BEGIN@10 at line 35
bool => sub { 1 }, '""' => 'as_string', fallback => 1;
# spent 40µs making 1 call to Exception::Class::Base::BEGIN@35 # spent 33µs making 1 call to overload::import
36
37# Create accessor routines
38
# spent 33µs within Exception::Class::Base::BEGIN@38 which was called: # once (33µs+0s) by Exception::Class::BEGIN@10 at line 67
BEGIN {
3912µs my @fields = qw( message pid uid euid gid egid time trace );
40
411500ns foreach my $f (@fields) {
4285µs my $sub = sub { my $s = shift; return $s->{$f}; };
43
44292µs225µs
# spent 16µs (7+9) within Exception::Class::Base::BEGIN@44 which was called: # once (7µs+9µs) by Exception::Class::BEGIN@10 at line 44
no strict 'refs';
# spent 16µs making 1 call to Exception::Class::Base::BEGIN@44 # spent 9µs making 1 call to strict::unimport
45812µs *{$f} = $sub;
46 }
471600ns *error = \&message;
48
4912µs my %trace_fields = (
50 package => 'package',
51 file => 'filename',
52 line => 'line',
53 );
54
5517µs while ( my ( $f, $m ) = each %trace_fields ) {
56 my $sub = sub {
57 my $s = shift;
58 return $s->{$f} if exists $s->{$f};
59
60 my $frame = $s->trace->frame(0);
61
62 return $s->{$f} = $frame ? $frame->$m() : undef;
6332µs };
64227µs225µs
# spent 17µs (9+8) within Exception::Class::Base::BEGIN@64 which was called: # once (9µs+8µs) by Exception::Class::BEGIN@10 at line 64
no strict 'refs';
# spent 17µs making 1 call to Exception::Class::Base::BEGIN@64 # spent 8µs making 1 call to strict::unimport
6533µs *{$f} = $sub;
66 }
671443µs133µs}
# spent 33µs making 1 call to Exception::Class::Base::BEGIN@38
68
691;
70
71sub Classes { Exception::Class::Classes() }
72
73
# spent 3.78ms (73µs+3.71) within Exception::Class::Base::throw which was called 8 times, avg 472µs/call: # 8 times (73µs+3.71ms) by Iterator::is_done at line 283 of Iterator.pm, avg 472µs/call
sub throw {
7483µs my $proto = shift;
75
7682µs $proto->rethrow if ref $proto;
77
788110µs83.71ms die $proto->new(@_);
# spent 3.71ms making 8 calls to Exception::Class::Base::new, avg 463µs/call
79}
80
81sub rethrow {
82 my $self = shift;
83
84 die $self;
85}
86
87
# spent 3.71ms (189µs+3.52) within Exception::Class::Base::new which was called 8 times, avg 463µs/call: # 8 times (189µs+3.52ms) by Exception::Class::Base::throw at line 78, avg 463µs/call
sub new {
8883µs my $proto = shift;
8982µs my $class = ref $proto || $proto;
90
918140µs my $self = bless {}, $class;
92
93818µs83.52ms $self->_initialize(@_);
# spent 3.52ms making 8 calls to Exception::Class::Base::_initialize, avg 440µs/call
94
95825µs return $self;
96}
97
98
# spent 3.52ms (417µs+3.10) within Exception::Class::Base::_initialize which was called 8 times, avg 440µs/call: # 8 times (417µs+3.10ms) by Exception::Class::Base::new at line 93, avg 440µs/call
sub _initialize {
9982µs my $self = shift;
10088µs my %p = @_ == 1 ? ( error => $_[0] ) : @_;
101
102815µs $self->{message} = $p{message} || $p{error} || '';
103
10483µs $self->{show_trace} = $p{show_trace} if exists $p{show_trace};
105
106825µs826µs if ( $self->NoContextInfo() ) {
# spent 26µs making 8 calls to Class::Data::Inheritable::__ANON__[Class/Data/Inheritable.pm:23], avg 3µs/call
107 $self->{show_trace} = 0;
108 $self->{package} = $self->{file} = $self->{line} = undef;
109 }
110 else {
111 # CORE::time is important to fix an error with some versions of
112 # Perl
113812µs $self->{time} = CORE::time();
114813µs $self->{pid} = $$;
115810µs $self->{uid} = $<;
11688µs $self->{euid} = $>;
117840µs $self->{gid} = $(;
118833µs $self->{egid} = $);
119
12087µs my @ignore_class = (__PACKAGE__);
12184µs my @ignore_package = 'Exception::Class';
122
12385µs if ( my $i = delete $p{ignore_class} ) {
124 push @ignore_class, ( ref($i) eq 'ARRAY' ? @$i : $i );
125 }
126
12783µs if ( my $i = delete $p{ignore_package} ) {
128 push @ignore_package, ( ref($i) eq 'ARRAY' ? @$i : $i );
129 }
130
1318104µs323.06ms $self->{trace} = Devel::StackTrace->new(
# spent 3.00ms making 8 calls to Devel::StackTrace::new, avg 375µs/call # spent 62µs making 24 calls to Class::Data::Inheritable::__ANON__[Class/Data/Inheritable.pm:23], avg 3µs/call
132 ignore_class => \@ignore_class,
133 ignore_package => \@ignore_package,
134 no_refs => $self->NoRefs,
135 respect_overload => $self->RespectOverload,
136 max_arg_length => $self->MaxArgLength,
137 );
138 }
139
140825µs812µs my %fields = map { $_ => 1 } $self->Fields;
# spent 12µs making 8 calls to Exception::Class::Base::Fields, avg 1µs/call
141834µs while ( my ( $key, $value ) = each %p ) {
142 next if $key =~ /^(?:error|message|show_trace)$/;
143
144 if ( $fields{$key} ) {
145 $self->{$key} = $value;
146 }
147 else {
148 Exception::Class::Base->throw(
149 error => "unknown field $key passed to constructor for class "
150 . ref $self );
151 }
152 }
153}
154
155sub description {
156 return 'Generic exception';
157}
158
159sub show_trace {
160 my $self = shift;
161
162 return 0 unless $self->{trace};
163
164 if (@_) {
165 $self->{show_trace} = shift;
166 }
167
168 return exists $self->{show_trace} ? $self->{show_trace} : $self->Trace;
169}
170
171sub as_string {
172 my $self = shift;
173
174 my $str = $self->full_message;
175 $str .= "\n\n" . $self->trace->as_string
176 if $self->show_trace;
177
178 return $str;
179}
180
181sub full_message { $_[0]->{message} }
182
183#
184# The %seen bit protects against circular inheritance.
185#
1861700nseval <<'EOF' if $] == 5.006;
187sub isa {
188 my ( $inheritor, $base ) = @_;
189 $inheritor = ref($inheritor) if ref($inheritor);
190
191 my %seen;
192
193 no strict 'refs';
194 my @parents = ( $inheritor, @{"$inheritor\::ISA"} );
195 while ( my $class = shift @parents ) {
196 return 1 if $class eq $base;
197
198 push @parents, grep { !$seen{$_}++ } @{"$class\::ISA"};
199 }
200 return 0;
201}
202EOF
203
204
# spent 226µs (187+38) within Exception::Class::Base::caught which was called 34 times, avg 7µs/call: # 26 times (142µs+31µs) by Iterator::value at line 229 of Iterator.pm, avg 7µs/call # 8 times (46µs+7µs) by Iterator::_initialize at line 172 of Iterator.pm, avg 7µs/call
sub caught {
2053412µs my $class = shift;
206
207349µs my $e = $@;
208
20934216µs4238µs return unless defined $e && blessed($e) && $e->isa($class);
# spent 29µs making 34 calls to Scalar::Util::blessed, avg 850ns/call # spent 9µs making 8 calls to UNIVERSAL::isa, avg 1µs/call
210822µs return $e;
211}
212
21315µs1;
214
215# ABSTRACT: A base class for exception objects
216
217__END__