Filename | /home/ss5/perl5/perlbrew/perls/tapper-perl/lib/site_perl/5.16.3/Exception/Class/Base.pm |
Statements | Executed 394 statements in 1.98ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
1 | 1 | 1 | 887µs | 3.29ms | BEGIN@10 | Exception::Class::Base::
8 | 1 | 1 | 417µs | 3.52ms | _initialize | Exception::Class::Base::
1 | 1 | 1 | 191µs | 244µs | BEGIN@9 | Exception::Class::Base::
8 | 1 | 1 | 189µs | 3.71ms | new | Exception::Class::Base::
34 | 2 | 1 | 187µs | 226µs | caught | Exception::Class::Base::
8 | 1 | 1 | 73µs | 3.78ms | throw | Exception::Class::Base::
1 | 1 | 1 | 38µs | 78µs | BEGIN@15 | Exception::Class::Base::
1 | 1 | 1 | 33µs | 33µs | BEGIN@38 | Exception::Class::Base::
1 | 1 | 1 | 17µs | 29µs | BEGIN@6 | Exception::Class::Base::
8 | 1 | 1 | 12µs | 12µs | Fields | Exception::Class::Base::
8 | 1 | 1 | 11µs | 11µs | __ANON__[:35] | Exception::Class::Base::
1 | 1 | 1 | 9µs | 17µs | BEGIN@64 | Exception::Class::Base::
1 | 1 | 1 | 7µs | 11µs | BEGIN@7 | Exception::Class::Base::
1 | 1 | 1 | 7µs | 28µs | BEGIN@11 | Exception::Class::Base::
1 | 1 | 1 | 7µs | 62µs | BEGIN@13 | Exception::Class::Base::
1 | 1 | 1 | 7µs | 40µs | BEGIN@35 | Exception::Class::Base::
1 | 1 | 1 | 7µs | 16µs | BEGIN@44 | Exception::Class::Base::
0 | 0 | 0 | 0s | 0s | Classes | Exception::Class::Base::
0 | 0 | 0 | 0s | 0s | __ANON__[:42] | Exception::Class::Base::
0 | 0 | 0 | 0s | 0s | __ANON__[:63] | Exception::Class::Base::
0 | 0 | 0 | 0s | 0s | as_string | Exception::Class::Base::
0 | 0 | 0 | 0s | 0s | description | Exception::Class::Base::
0 | 0 | 0 | 0s | 0s | full_message | Exception::Class::Base::
0 | 0 | 0 | 0s | 0s | rethrow | Exception::Class::Base::
0 | 0 | 0 | 0s | 0s | show_trace | Exception::Class::Base::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | package Exception::Class::Base; | ||||
2 | { | ||||
3 | 2 | 2µs | $Exception::Class::Base::VERSION = '1.37'; | ||
4 | } | ||||
5 | |||||
6 | 2 | 22µs | 2 | 40µ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 # spent 29µs making 1 call to Exception::Class::Base::BEGIN@6
# spent 12µs making 1 call to strict::import |
7 | 2 | 20µs | 2 | 14µ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 # spent 11µs making 1 call to Exception::Class::Base::BEGIN@7
# spent 3µs making 1 call to warnings::import |
8 | |||||
9 | 3 | 96µs | 2 | 253µ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 # spent 244µs making 1 call to Exception::Class::Base::BEGIN@9
# spent 9µs making 1 call to UNIVERSAL::VERSION |
10 | 3 | 93µs | 2 | 3.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 # spent 3.29ms making 1 call to Exception::Class::Base::BEGIN@10
# spent 9µs making 1 call to UNIVERSAL::VERSION |
11 | 2 | 21µs | 2 | 48µ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 # spent 28µs making 1 call to Exception::Class::Base::BEGIN@11
# spent 21µs making 1 call to Exporter::import |
12 | |||||
13 | 2 | 55µs | 2 | 116µ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 # 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 | ||||
16 | 1 | 4µs | 1 | 8µs | __PACKAGE__->mk_classdata('Trace'); # spent 8µs making 1 call to Class::Data::Inheritable::mk_classdata |
17 | 1 | 2µs | 1 | 6µs | __PACKAGE__->mk_classdata('NoRefs'); # spent 6µs making 1 call to Class::Data::Inheritable::mk_classdata |
18 | 1 | 2µs | 1 | 2µs | __PACKAGE__->NoRefs(1); # spent 2µs making 1 call to Class::Data::Inheritable::__ANON__[Class/Data/Inheritable.pm:23] |
19 | |||||
20 | 1 | 1µs | 1 | 6µs | __PACKAGE__->mk_classdata('NoContextInfo'); # spent 6µs making 1 call to Class::Data::Inheritable::mk_classdata |
21 | 1 | 2µs | 1 | 2µs | __PACKAGE__->NoContextInfo(0); # spent 2µs making 1 call to Class::Data::Inheritable::__ANON__[Class/Data/Inheritable.pm:23] |
22 | |||||
23 | 1 | 1µs | 1 | 6µs | __PACKAGE__->mk_classdata('RespectOverload'); # spent 6µs making 1 call to Class::Data::Inheritable::mk_classdata |
24 | 1 | 2µs | 1 | 2µs | __PACKAGE__->RespectOverload(0); # spent 2µs making 1 call to Class::Data::Inheritable::__ANON__[Class/Data/Inheritable.pm:23] |
25 | |||||
26 | 1 | 1µs | 1 | 6µs | __PACKAGE__->mk_classdata('MaxArgLength'); # spent 6µs making 1 call to Class::Data::Inheritable::mk_classdata |
27 | 1 | 4µs | 1 | 2µs | __PACKAGE__->MaxArgLength(0); # spent 2µs making 1 call to Class::Data::Inheritable::__ANON__[Class/Data/Inheritable.pm:23] |
28 | |||||
29 | 8 | 24µ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 | ||
30 | 1 | 27µs | 1 | 78µs | } # spent 78µs making 1 call to Exception::Class::Base::BEGIN@15 |
31 | |||||
32 | use overload | ||||
33 | |||||
34 | # an exception is always true | ||||
35 | 10 | 80µs | 2 | 73µ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 # 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 | ||||
39 | 1 | 2µs | my @fields = qw( message pid uid euid gid egid time trace ); | ||
40 | |||||
41 | 1 | 500ns | foreach my $f (@fields) { | ||
42 | 8 | 5µs | my $sub = sub { my $s = shift; return $s->{$f}; }; | ||
43 | |||||
44 | 2 | 92µs | 2 | 25µ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 # spent 16µs making 1 call to Exception::Class::Base::BEGIN@44
# spent 9µs making 1 call to strict::unimport |
45 | 8 | 12µs | *{$f} = $sub; | ||
46 | } | ||||
47 | 1 | 600ns | *error = \&message; | ||
48 | |||||
49 | 1 | 2µs | my %trace_fields = ( | ||
50 | package => 'package', | ||||
51 | file => 'filename', | ||||
52 | line => 'line', | ||||
53 | ); | ||||
54 | |||||
55 | 1 | 7µ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; | ||||
63 | 3 | 2µs | }; | ||
64 | 2 | 27µs | 2 | 25µ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 # spent 17µs making 1 call to Exception::Class::Base::BEGIN@64
# spent 8µs making 1 call to strict::unimport |
65 | 3 | 3µs | *{$f} = $sub; | ||
66 | } | ||||
67 | 1 | 443µs | 1 | 33µs | } # spent 33µs making 1 call to Exception::Class::Base::BEGIN@38 |
68 | |||||
69 | 1; | ||||
70 | |||||
71 | sub 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 | ||||
74 | 8 | 3µs | my $proto = shift; | ||
75 | |||||
76 | 8 | 2µs | $proto->rethrow if ref $proto; | ||
77 | |||||
78 | 8 | 110µs | 8 | 3.71ms | die $proto->new(@_); # spent 3.71ms making 8 calls to Exception::Class::Base::new, avg 463µs/call |
79 | } | ||||
80 | |||||
81 | sub 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 | ||||
88 | 8 | 3µs | my $proto = shift; | ||
89 | 8 | 2µs | my $class = ref $proto || $proto; | ||
90 | |||||
91 | 8 | 140µs | my $self = bless {}, $class; | ||
92 | |||||
93 | 8 | 18µs | 8 | 3.52ms | $self->_initialize(@_); # spent 3.52ms making 8 calls to Exception::Class::Base::_initialize, avg 440µs/call |
94 | |||||
95 | 8 | 25µ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 | ||||
99 | 8 | 2µs | my $self = shift; | ||
100 | 8 | 8µs | my %p = @_ == 1 ? ( error => $_[0] ) : @_; | ||
101 | |||||
102 | 8 | 15µs | $self->{message} = $p{message} || $p{error} || ''; | ||
103 | |||||
104 | 8 | 3µs | $self->{show_trace} = $p{show_trace} if exists $p{show_trace}; | ||
105 | |||||
106 | 8 | 25µs | 8 | 26µ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 | ||||
113 | 8 | 12µs | $self->{time} = CORE::time(); | ||
114 | 8 | 13µs | $self->{pid} = $$; | ||
115 | 8 | 10µs | $self->{uid} = $<; | ||
116 | 8 | 8µs | $self->{euid} = $>; | ||
117 | 8 | 40µs | $self->{gid} = $(; | ||
118 | 8 | 33µs | $self->{egid} = $); | ||
119 | |||||
120 | 8 | 7µs | my @ignore_class = (__PACKAGE__); | ||
121 | 8 | 4µs | my @ignore_package = 'Exception::Class'; | ||
122 | |||||
123 | 8 | 5µs | if ( my $i = delete $p{ignore_class} ) { | ||
124 | push @ignore_class, ( ref($i) eq 'ARRAY' ? @$i : $i ); | ||||
125 | } | ||||
126 | |||||
127 | 8 | 3µs | if ( my $i = delete $p{ignore_package} ) { | ||
128 | push @ignore_package, ( ref($i) eq 'ARRAY' ? @$i : $i ); | ||||
129 | } | ||||
130 | |||||
131 | 8 | 104µs | 32 | 3.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 | |||||
140 | 8 | 25µs | 8 | 12µs | my %fields = map { $_ => 1 } $self->Fields; # spent 12µs making 8 calls to Exception::Class::Base::Fields, avg 1µs/call |
141 | 8 | 34µ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 | |||||
155 | sub description { | ||||
156 | return 'Generic exception'; | ||||
157 | } | ||||
158 | |||||
159 | sub 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 | |||||
171 | sub 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 | |||||
181 | sub full_message { $_[0]->{message} } | ||||
182 | |||||
183 | # | ||||
184 | # The %seen bit protects against circular inheritance. | ||||
185 | # | ||||
186 | 1 | 700ns | eval <<'EOF' if $] == 5.006; | ||
187 | sub 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 | } | ||||
202 | EOF | ||||
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 | ||||
205 | 34 | 12µs | my $class = shift; | ||
206 | |||||
207 | 34 | 9µs | my $e = $@; | ||
208 | |||||
209 | 34 | 216µs | 42 | 38µ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 |
210 | 8 | 22µs | return $e; | ||
211 | } | ||||
212 | |||||
213 | 1 | 5µs | 1; | ||
214 | |||||
215 | # ABSTRACT: A base class for exception objects | ||||
216 | |||||
217 | __END__ |