← Index
NYTProf Performance Profile   « block view • line view • sub view »
For bin/pan_genome_post_analysis
  Run on Fri Mar 27 11:43:32 2015
Reported on Fri Mar 27 11:45:42 2015

Filename/Users/ap13/perl5/lib/perl5/Exception/Class.pm
StatementsExecuted 82 statements in 1.17ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
1111.21ms4.09msException::Class::::BEGIN@9Exception::Class::BEGIN@9
211190µs350µsException::Class::::_make_subclassException::Class::_make_subclass
11136µs400µsException::Class::::importException::Class::import
11120µs20µsException::Class::::BEGIN@5Exception::Class::BEGIN@5
11113µs13µsException::Class::::CORE:sortException::Class::CORE:sort (opcode)
11111µs21µsException::Class::::BEGIN@45Exception::Class::BEGIN@45
1119µs32µsException::Class::::BEGIN@10Exception::Class::BEGIN@10
1119µs24µsException::Class::::BEGIN@7Exception::Class::BEGIN@7
1118µs18µsException::Class::::BEGIN@167Exception::Class::BEGIN@167
1118µs17µsException::Class::::BEGIN@175Exception::Class::BEGIN@175
1117µs17µsException::Class::::BEGIN@78Exception::Class::BEGIN@78
1113µs3µsException::Class::::BEGIN@13Exception::Class::BEGIN@13
2112µs2µsException::Class::::CORE:substException::Class::CORE:subst (opcode)
0000s0sException::Class::::ClassesException::Class::Classes
0000s0sException::Class::::__ANON__[:169]Exception::Class::__ANON__[:169]
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;
2# git description: v1.38-8-gbef365d
3
41600ns$Exception::Class::VERSION = '1.39';
5248µs120µs
# spent 20µs within Exception::Class::BEGIN@5 which was called: # once (20µs+0s) by Bio::Roary::Exceptions::BEGIN@11 at line 5
use 5.008001;
# spent 20µs making 1 call to Exception::Class::BEGIN@5
6
7224µs240µs
# spent 24µs (9+16) within Exception::Class::BEGIN@7 which was called: # once (9µs+16µs) by Bio::Roary::Exceptions::BEGIN@11 at line 7
use strict;
# spent 24µs making 1 call to Exception::Class::BEGIN@7 # spent 16µs making 1 call to strict::import
8
92115µs14.09ms
# spent 4.09ms (1.21+2.88) within Exception::Class::BEGIN@9 which was called: # once (1.21ms+2.88ms) by Bio::Roary::Exceptions::BEGIN@11 at line 9
use Exception::Class::Base;
# spent 4.09ms making 1 call to Exception::Class::BEGIN@9
10234µs255µs
# spent 32µs (9+23) within Exception::Class::BEGIN@10 which was called: # once (9µs+23µs) by Bio::Roary::Exceptions::BEGIN@11 at line 10
use Scalar::Util qw(blessed);
# spent 32µs making 1 call to Exception::Class::BEGIN@10 # spent 23µs making 1 call to Exporter::import
11
1210sour $BASE_EXC_CLASS;
131110µs13µs
# spent 3µs within Exception::Class::BEGIN@13 which was called: # once (3µs+0s) by Bio::Roary::Exceptions::BEGIN@11 at line 13
BEGIN { $BASE_EXC_CLASS ||= 'Exception::Class::Base'; }
# spent 3µs making 1 call to Exception::Class::BEGIN@13
14
151200nsour %CLASSES;
16
17
# spent 400µs (36+364) within Exception::Class::import which was called: # once (36µs+364µs) by Bio::Roary::Exceptions::BEGIN@11 at line 14 of lib/Bio/Roary/Exceptions.pm
sub import {
18730µs my $class = shift;
19
20 local $Exception::Class::Caller = caller();
21
22 my %c;
23
24 my %needs_parent;
2564µs while ( my $subclass = shift ) {
26 my $def = ref $_[0] ? shift : {};
27 $def->{isa}
28 = $def->{isa}
29 ? ( ref $def->{isa} ? $def->{isa} : [ $def->{isa} ] )
30 : [];
31
32 $c{$subclass} = $def;
33 }
34
35 # We need to sort by length because if we check for keys in the
36 # Foo::Bar:: stash, this creates a "Bar::" key in the Foo:: stash!
37MAKE_CLASSES:
38113µs foreach my $subclass ( sort { length $a <=> length $b } keys %c ) {
# spent 13µs making 1 call to Exception::Class::CORE:sort
3988µs my $def = $c{$subclass};
40
41 # We already made this one.
42 next if $CLASSES{$subclass};
43
44 {
452132µs231µs
# spent 21µs (11+10) within Exception::Class::BEGIN@45 which was called: # once (11µs+10µs) by Bio::Roary::Exceptions::BEGIN@11 at line 45
no strict 'refs';
# spent 21µs making 1 call to Exception::Class::BEGIN@45 # spent 10µs making 1 call to strict::unimport
4622µs foreach my $parent ( @{ $def->{isa} } ) {
47 unless ( keys %{"$parent\::"} ) {
48 $needs_parent{$subclass} = {
49 parents => $def->{isa},
50 def => $def
51 };
52 next MAKE_CLASSES;
53 }
54 }
55 }
56
57 $class->_make_subclass(
582350µs subclass => $subclass,
# spent 350µs making 2 calls to Exception::Class::_make_subclass, avg 175µs/call
59 def => $def || {},
60 );
61 }
62
63 foreach my $subclass ( keys %needs_parent ) {
64
65 # This will be used to spot circular references.
66 my %seen;
67 $class->_make_parents( \%needs_parent, $subclass, \%seen );
68 }
69}
70
71sub _make_parents {
72 my $class = shift;
73 my $needs = shift;
74 my $subclass = shift;
75 my $seen = shift;
76 my $child = shift; # Just for error messages.
77
782323µs227µs
# spent 17µs (7+10) within Exception::Class::BEGIN@78 which was called: # once (7µs+10µs) by Bio::Roary::Exceptions::BEGIN@11 at line 78
no strict 'refs';
# spent 17µs making 1 call to Exception::Class::BEGIN@78 # spent 10µs making 1 call to strict::unimport
79
80 # What if someone makes a typo in specifying their 'isa' param?
81 # This should catch it. Either it's been made because it didn't
82 # have missing parents OR it's in our hash as needing a parent.
83 # If neither of these is true then the _only_ place it is
84 # mentioned is in the 'isa' param for some other class, which is
85 # not a good enough reason to make a new class.
86 die
87 "Class $subclass appears to be a typo as it is only specified in the 'isa' param for $child\n"
88 unless exists $needs->{$subclass}
89 || $CLASSES{$subclass}
90 || keys %{"$subclass\::"};
91
92 foreach my $c ( @{ $needs->{$subclass}{parents} } ) {
93
94 # It's been made
95 next if $CLASSES{$c} || keys %{"$c\::"};
96
97 die "There appears to be some circularity involving $subclass\n"
98 if $seen->{$subclass};
99
100 $seen->{$subclass} = 1;
101
102 $class->_make_parents( $needs, $c, $seen, $subclass );
103 }
104
105 return if $CLASSES{$subclass} || keys %{"$subclass\::"};
106
107 $class->_make_subclass(
108 subclass => $subclass,
109 def => $needs->{$subclass}{def}
110 );
111}
112
113
# spent 350µs (190+160) within Exception::Class::_make_subclass which was called 2 times, avg 175µs/call: # 2 times (190µs+160µs) by Exception::Class::import at line 58, avg 175µs/call
sub _make_subclass {
11434100µs my $class = shift;
115 my %p = @_;
116
117 my $subclass = $p{subclass};
118 my $def = $p{def};
119
120 my $isa;
121 if ( $def->{isa} ) {
122 $isa = ref $def->{isa} ? join ' ', @{ $def->{isa} } : $def->{isa};
123 }
124 $isa ||= $BASE_EXC_CLASS;
125
126 my $version_name = 'VERSION';
127
128 my $code = <<"EOPERL";
129package $subclass;
130
131use base qw($isa);
132
133our \$$version_name = '1.1';
134
1351;
136
137EOPERL
138
139413µs if ( $def->{description} ) {
14022µs ( my $desc = $def->{description} ) =~ s/([\\\'])/\\$1/g;
# spent 2µs making 2 calls to Exception::Class::CORE:subst, avg 1µs/call
141 $code .= <<"EOPERL";
142sub description
143{
144 return '$desc';
145}
146EOPERL
147 }
148
149 my @fields;
150 if ( my $fields = $def->{fields} ) {
151 @fields = UNIVERSAL::isa( $fields, 'ARRAY' ) ? @$fields : $fields;
152
153 $code
154 .= "sub Fields { return (\$_[0]->SUPER::Fields, "
155 . join( ", ", map { "'$_'" } @fields )
156 . ") }\n\n";
157
158 foreach my $field (@fields) {
159 $code .= sprintf( "sub %s { \$_[0]->{%s} }\n", $field, $field );
160 }
161 }
162
163 if ( my $alias = $def->{alias} ) {
164 die "Cannot make alias without caller"
165 unless defined $Exception::Class::Caller;
166
167270µs228µs
# spent 18µs (8+10) within Exception::Class::BEGIN@167 which was called: # once (8µs+10µs) by Bio::Roary::Exceptions::BEGIN@11 at line 167
no strict 'refs';
# spent 18µs making 1 call to Exception::Class::BEGIN@167 # spent 10µs making 1 call to strict::unimport
168 *{"$Exception::Class::Caller\::$alias"}
169 = sub { $subclass->throw(@_) };
170 }
171
172 if ( my $defaults = $def->{defaults} ) {
173 $code
174 .= "sub _defaults { return shift->SUPER::_defaults, our \%_DEFAULTS }\n";
1752158µs226µs
# spent 17µs (8+9) within Exception::Class::BEGIN@175 which was called: # once (8µs+9µs) by Bio::Roary::Exceptions::BEGIN@11 at line 175
no strict 'refs';
# spent 17µs making 1 call to Exception::Class::BEGIN@175 # spent 9µs making 1 call to strict::unimport
176 *{"$subclass\::_DEFAULTS"} = {%$defaults};
177 }
178
179 eval $code;
# spent 58µs executing statements in string eval
# includes 13µs spent executing 1 call to 2 subs defined therein. # spent 38µs executing statements in string eval
# includes 11µs spent executing 1 call to 2 subs defined therein.
180
181 die $@ if $@;
182
183 $CLASSES{$subclass} = 1;
184}
185
186sub caught {
187 my $e = $@;
188
189 return $e unless $_[1];
190
191 return unless blessed($e) && $e->isa( $_[1] );
192 return $e;
193}
194
195sub Classes { sort keys %Exception::Class::CLASSES }
196
19714µs1;
198
199# ABSTRACT: A module that allows you to declare real exception classes in Perl
200
201__END__
 
# spent 13µs within Exception::Class::CORE:sort which was called: # once (13µs+0s) by Exception::Class::import at line 38
sub Exception::Class::CORE:sort; # opcode
# spent 2µs within Exception::Class::CORE:subst which was called 2 times, avg 1µs/call: # 2 times (2µs+0s) by Exception::Class::_make_subclass at line 140, avg 1µs/call
sub Exception::Class::CORE:subst; # opcode