← Index
NYTProf Performance Profile   « line view »
For t/optimization.t
  Run on Thu Jan 8 22:47:42 2015
Reported on Thu Jan 8 22:48:06 2015

Filename/home/ss5/perl5/perlbrew/perls/tapper-perl/lib/site_perl/5.16.3/Exception/Class/Base.pm
StatementsExecuted 60 statements in 1.45ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
1111.31ms4.40msException::Class::Base::::BEGIN@10Exception::Class::Base::BEGIN@10
111273µs345µsException::Class::Base::::BEGIN@9Exception::Class::Base::BEGIN@9
11160µs60µsException::Class::Base::::BEGIN@38Exception::Class::Base::BEGIN@38
11158µs150µsException::Class::Base::::BEGIN@15Exception::Class::Base::BEGIN@15
11114µs28µsException::Class::Base::::BEGIN@6Exception::Class::Base::BEGIN@6
11110µs58µsException::Class::Base::::BEGIN@35Exception::Class::Base::BEGIN@35
11110µs40µsException::Class::Base::::BEGIN@11Exception::Class::Base::BEGIN@11
11110µs23µsException::Class::Base::::BEGIN@44Exception::Class::Base::BEGIN@44
11110µs15µsException::Class::Base::::BEGIN@7Exception::Class::Base::BEGIN@7
11110µs22µsException::Class::Base::::BEGIN@64Exception::Class::Base::BEGIN@64
11110µs85µsException::Class::Base::::BEGIN@13Exception::Class::Base::BEGIN@13
0000s0sException::Class::Base::::ClassesException::Class::Base::Classes
0000s0sException::Class::Base::::FieldsException::Class::Base::Fields
0000s0sException::Class::Base::::__ANON__[:35]Exception::Class::Base::__ANON__[:35]
0000s0sException::Class::Base::::__ANON__[:42]Exception::Class::Base::__ANON__[:42]
0000s0sException::Class::Base::::__ANON__[:63]Exception::Class::Base::__ANON__[:63]
0000s0sException::Class::Base::::_initializeException::Class::Base::_initialize
0000s0sException::Class::Base::::as_stringException::Class::Base::as_string
0000s0sException::Class::Base::::caughtException::Class::Base::caught
0000s0sException::Class::Base::::descriptionException::Class::Base::description
0000s0sException::Class::Base::::full_messageException::Class::Base::full_message
0000s0sException::Class::Base::::newException::Class::Base::new
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;
2{
322µs $Exception::Class::Base::VERSION = '1.37';
4}
5
6229µs242µs
# spent 28µs (14+14) within Exception::Class::Base::BEGIN@6 which was called: # once (14µs+14µs) by Exception::Class::BEGIN@10 at line 6
use strict;
# spent 28µs making 1 call to Exception::Class::Base::BEGIN@6 # spent 14µs making 1 call to strict::import
7231µs220µs
# spent 15µs (10+5) within Exception::Class::Base::BEGIN@7 which was called: # once (10µs+5µs) by Exception::Class::BEGIN@10 at line 7
use warnings;
# spent 15µs making 1 call to Exception::Class::Base::BEGIN@7 # spent 5µs making 1 call to warnings::import
8
93129µs2358µs
# spent 345µs (273+72) within Exception::Class::Base::BEGIN@9 which was called: # once (273µs+72µs) by Exception::Class::BEGIN@10 at line 9
use Class::Data::Inheritable 0.02;
# spent 345µs making 1 call to Exception::Class::Base::BEGIN@9 # spent 13µs making 1 call to UNIVERSAL::VERSION
103132µs24.41ms
# spent 4.40ms (1.31+3.09) within Exception::Class::Base::BEGIN@10 which was called: # once (1.31ms+3.09ms) by Exception::Class::BEGIN@10 at line 10
use Devel::StackTrace 1.20;
# spent 4.40ms making 1 call to Exception::Class::Base::BEGIN@10 # spent 13µs making 1 call to UNIVERSAL::VERSION
11230µs270µs
# spent 40µs (10+30) within Exception::Class::Base::BEGIN@11 which was called: # once (10µs+30µs) by Exception::Class::BEGIN@10 at line 11
use Scalar::Util qw( blessed );
# spent 40µs making 1 call to Exception::Class::Base::BEGIN@11 # spent 30µs making 1 call to Exporter::import
12
13280µs2160µs
# spent 85µs (10+75) within Exception::Class::Base::BEGIN@13 which was called: # once (10µs+75µs) by Exception::Class::BEGIN@10 at line 13
use base qw(Class::Data::Inheritable);
# spent 85µs making 1 call to Exception::Class::Base::BEGIN@13 # spent 75µs making 1 call to base::import
14
15
# spent 150µs (58+92) within Exception::Class::Base::BEGIN@15 which was called: # once (58µs+92µs) by Exception::Class::BEGIN@10 at line 30
BEGIN {
1615µs112µs __PACKAGE__->mk_classdata('Trace');
# spent 12µs making 1 call to Class::Data::Inheritable::mk_classdata
1712µs139µs __PACKAGE__->mk_classdata('NoRefs');
# spent 39µs making 1 call to Class::Data::Inheritable::mk_classdata
1815µs15µs __PACKAGE__->NoRefs(1);
19
2012µs110µs __PACKAGE__->mk_classdata('NoContextInfo');
# spent 10µs making 1 call to Class::Data::Inheritable::mk_classdata
2112µs12µs __PACKAGE__->NoContextInfo(0);
22
2312µs110µs __PACKAGE__->mk_classdata('RespectOverload');
# spent 10µs making 1 call to Class::Data::Inheritable::mk_classdata
2412µs12µs __PACKAGE__->RespectOverload(0);
25
2612µs19µs __PACKAGE__->mk_classdata('MaxArgLength');
# spent 9µs making 1 call to Class::Data::Inheritable::mk_classdata
2716µs13µs __PACKAGE__->MaxArgLength(0);
28
29 sub Fields { () }
30145µs1150µs}
# spent 150µs making 1 call to Exception::Class::Base::BEGIN@15
31
32use overload
33
34 # an exception is always true
35286µs2105µs
# spent 58µs (10+47) within Exception::Class::Base::BEGIN@35 which was called: # once (10µs+47µs) by Exception::Class::BEGIN@10 at line 35
bool => sub { 1 }, '""' => 'as_string', fallback => 1;
# spent 58µs making 1 call to Exception::Class::Base::BEGIN@35 # spent 47µs making 1 call to overload::import
36
37# Create accessor routines
38
# spent 60µs within Exception::Class::Base::BEGIN@38 which was called: # once (60µ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
411700ns foreach my $f (@fields) {
42817µs my $sub = sub { my $s = shift; return $s->{$f}; };
43
442131µs237µs
# spent 23µs (10+13) within Exception::Class::Base::BEGIN@44 which was called: # once (10µs+13µs) by Exception::Class::BEGIN@10 at line 44
no strict 'refs';
# spent 23µs making 1 call to Exception::Class::Base::BEGIN@44 # spent 13µs making 1 call to strict::unimport
45815µs *{$f} = $sub;
46 }
471800ns *error = \&message;
48
4912µs my %trace_fields = (
50 package => 'package',
51 file => 'filename',
52 line => 'line',
53 );
54
55111µ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;
6337µs };
64238µs235µs
# spent 22µs (10+13) within Exception::Class::Base::BEGIN@64 which was called: # once (10µs+13µs) by Exception::Class::BEGIN@10 at line 64
no strict 'refs';
# spent 22µs making 1 call to Exception::Class::Base::BEGIN@64 # spent 13µs making 1 call to strict::unimport
6534µs *{$f} = $sub;
66 }
671620µs160µs}
# spent 60µs making 1 call to Exception::Class::Base::BEGIN@38
68
691;
70
71sub Classes { Exception::Class::Classes() }
72
73sub throw {
74 my $proto = shift;
75
76 $proto->rethrow if ref $proto;
77
78 die $proto->new(@_);
79}
80
81sub rethrow {
82 my $self = shift;
83
84 die $self;
85}
86
87sub new {
88 my $proto = shift;
89 my $class = ref $proto || $proto;
90
91 my $self = bless {}, $class;
92
93 $self->_initialize(@_);
94
95 return $self;
96}
97
98sub _initialize {
99 my $self = shift;
100 my %p = @_ == 1 ? ( error => $_[0] ) : @_;
101
102 $self->{message} = $p{message} || $p{error} || '';
103
104 $self->{show_trace} = $p{show_trace} if exists $p{show_trace};
105
106 if ( $self->NoContextInfo() ) {
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
113 $self->{time} = CORE::time();
114 $self->{pid} = $$;
115 $self->{uid} = $<;
116 $self->{euid} = $>;
117 $self->{gid} = $(;
118 $self->{egid} = $);
119
120 my @ignore_class = (__PACKAGE__);
121 my @ignore_package = 'Exception::Class';
122
123 if ( my $i = delete $p{ignore_class} ) {
124 push @ignore_class, ( ref($i) eq 'ARRAY' ? @$i : $i );
125 }
126
127 if ( my $i = delete $p{ignore_package} ) {
128 push @ignore_package, ( ref($i) eq 'ARRAY' ? @$i : $i );
129 }
130
131 $self->{trace} = Devel::StackTrace->new(
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
140 my %fields = map { $_ => 1 } $self->Fields;
141 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
204sub caught {
205 my $class = shift;
206
207 my $e = $@;
208
209 return unless defined $e && blessed($e) && $e->isa($class);
210 return $e;
211}
212
21314µs1;
214
215# ABSTRACT: A base class for exception objects
216
217__END__