Filename | /Users/ap13/perl5/perlbrew/perls/perl-5.16.2/lib/5.16.2/base.pm |
Statements | Executed 2174 statements in 6.68ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
61 | 61 | 60 | 25.8ms | 75.4ms | import (recurses: max depth 3, inclusive time 30.6ms) | base::
1 | 1 | 1 | 674µs | 1.36ms | BEGIN@4 | base::
88 | 1 | 1 | 315µs | 315µs | has_fields | base::
88 | 1 | 1 | 234µs | 234µs | has_attr | base::
1 | 1 | 1 | 20µs | 38µs | BEGIN@3 | base::
0 | 0 | 0 | 0s | 0s | __ANON__[:48] | base::
0 | 0 | 0 | 0s | 0s | __ANON__[:55] | base::
0 | 0 | 0 | 0s | 0s | get_attr | base::
0 | 0 | 0 | 0s | 0s | inherit_fields | base::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | package base; | ||||
2 | |||||
3 | 2 | 46µs | 2 | 57µs | # spent 38µs (20+18) within base::BEGIN@3 which was called:
# once (20µs+18µs) by Class::Load::BEGIN@7 at line 3 # spent 38µs making 1 call to base::BEGIN@3
# spent 18µs making 1 call to strict::import |
4 | 2 | 998µs | 2 | 1.39ms | # spent 1.36ms (674µs+684µs) within base::BEGIN@4 which was called:
# once (674µs+684µs) by Class::Load::BEGIN@7 at line 4 # spent 1.36ms making 1 call to base::BEGIN@4
# spent 35µs making 1 call to vars::import |
5 | 1 | 1µs | $VERSION = '2.18'; | ||
6 | 1 | 24µs | $VERSION = eval $VERSION; # spent 2µs executing statements in string eval | ||
7 | |||||
8 | # constant.pm is slow | ||||
9 | sub SUCCESS () { 1 } | ||||
10 | |||||
11 | sub PUBLIC () { 2**0 } | ||||
12 | sub PRIVATE () { 2**1 } | ||||
13 | sub INHERITED () { 2**2 } | ||||
14 | sub PROTECTED () { 2**3 } | ||||
15 | |||||
16 | |||||
17 | 1 | 800ns | my $Fattr = \%fields::attr; | ||
18 | |||||
19 | # spent 315µs within base::has_fields which was called 88 times, avg 4µs/call:
# 88 times (315µs+0s) by base::import at line 101, avg 4µs/call | ||||
20 | 88 | 48µs | my($base) = shift; | ||
21 | 88 | 80µs | my $fglob = ${"$base\::"}{FIELDS}; | ||
22 | 88 | 291µs | return( ($fglob && 'GLOB' eq ref($fglob) && *$fglob{HASH}) ? 1 : 0 ); | ||
23 | } | ||||
24 | |||||
25 | # spent 234µs within base::has_attr which was called 88 times, avg 3µs/call:
# 88 times (234µs+0s) by base::import at line 101, avg 3µs/call | ||||
26 | 88 | 34µs | my($proto) = shift; | ||
27 | 88 | 32µs | my($class) = ref $proto || $proto; | ||
28 | 88 | 206µs | return exists $Fattr->{$class}; | ||
29 | } | ||||
30 | |||||
31 | sub get_attr { | ||||
32 | $Fattr->{$_[0]} = [1] unless $Fattr->{$_[0]}; | ||||
33 | return $Fattr->{$_[0]}; | ||||
34 | } | ||||
35 | |||||
36 | 1 | 2µs | if ($] < 5.009) { | ||
37 | *get_fields = sub { | ||||
38 | # Shut up a possible typo warning. | ||||
39 | () = \%{$_[0].'::FIELDS'}; | ||||
40 | my $f = \%{$_[0].'::FIELDS'}; | ||||
41 | |||||
42 | # should be centralized in fields? perhaps | ||||
43 | # fields::mk_FIELDS_be_OK. Peh. As long as %{ $package . '::FIELDS' } | ||||
44 | # is used here anyway, it doesn't matter. | ||||
45 | bless $f, 'pseudohash' if (ref($f) ne 'pseudohash'); | ||||
46 | |||||
47 | return $f; | ||||
48 | } | ||||
49 | } | ||||
50 | else { | ||||
51 | *get_fields = sub { | ||||
52 | # Shut up a possible typo warning. | ||||
53 | () = \%{$_[0].'::FIELDS'}; | ||||
54 | return \%{$_[0].'::FIELDS'}; | ||||
55 | } | ||||
56 | 1 | 3µs | } | ||
57 | |||||
58 | # spent 75.4ms (25.8+49.6) within base::import which was called 61 times, avg 1.24ms/call:
# once (1.80ms+35.2ms) by Bio::Seq::SeqFactory::BEGIN@83 at line 83 of Bio/Seq/SeqFactory.pm
# once (3.71ms+15.9ms) by Bio::LocatableSeq::BEGIN@120 at line 120 of Bio/LocatableSeq.pm
# once (2.10ms+5.12ms) by Bio::SeqFeature::Generic::BEGIN@151 at line 151 of Bio/SeqFeature/Generic.pm
# once (1.62ms+4.59ms) by Bio::Location::Simple::BEGIN@87 at line 87 of Bio/Location/Simple.pm
# once (373µs+215µs) by Bio::Tools::GFF::BEGIN@154 at line 154 of Bio/Tools/GFF.pm
# once (391µs+182µs) by Bio::Location::Split::BEGIN@101 at line 101 of Bio/Location/Split.pm
# once (389µs+141µs) by Bio::Location::Fuzzy::BEGIN@84 at line 84 of Bio/Location/Fuzzy.pm
# once (400µs+124µs) by Bio::Annotation::Collection::BEGIN@96 at line 96 of Bio/Annotation/Collection.pm
# once (351µs+147µs) by Bio::Seq::SeqBuilder::BEGIN@133 at line 133 of Bio/Seq/SeqBuilder.pm
# once (304µs+168µs) by Bio::Factory::FTLocationFactory::BEGIN@102 at line 102 of Bio/Factory/FTLocationFactory.pm
# once (341µs+117µs) by Bio::Annotation::SimpleValue::BEGIN@82 at line 82 of Bio/Annotation/SimpleValue.pm
# once (114µs+17µs) by Graph::Traversal::DFS::BEGIN@6 at line 6 of Graph/Traversal/DFS.pm
# once (102µs+14µs) by Sub::Name::BEGIN@49 at line 49 of Sub/Name.pm
# once (96µs+14µs) by Graph::AdjacencyMatrix::BEGIN@8 at line 8 of Graph/AdjacencyMatrix.pm
# once (97µs+12µs) by Graph::SPTHeapElem::BEGIN@7 at line 7 of Graph/SPTHeapElem.pm
# once (94µs+14µs) by Graph::MSTHeapElem::BEGIN@7 at line 7 of Graph/MSTHeapElem.pm
# once (95µs+11µs) by Graph::Undirected::BEGIN@4 at line 4 of Graph/Undirected.pm
# once (90µs+10µs) by Bio::Factory::SequenceStreamI::BEGIN@80 at line 80 of Bio/Factory/SequenceStreamI.pm
# once (82µs+10µs) by Class::Load::BEGIN@7 at line 7 of Class/Load.pm
# once (69µs+13µs) by Moose::Meta::TypeConstraint::BEGIN@18 at line 18 of Moose/Meta/TypeConstraint.pm
# once (71µs+10µs) by Sub::Name::BEGIN@50 at line 50 of Sub/Name.pm
# once (64µs+11µs) by Bio::Roary::Exceptions::FileNotFound::BEGIN@3 at line 3 of (eval 180)[Exception/Class.pm:179]
# once (65µs+8µs) by Bio::Annotation::TypeManager::BEGIN@86 at line 86 of Bio/Annotation/TypeManager.pm
# once (62µs+10µs) by Exception::Class::Base::BEGIN@10 at line 10 of Exception/Class/Base.pm
# once (62µs+10µs) by Graph::AdjacencyMap::Heavy::BEGIN@13 at line 13 of Graph/AdjacencyMap/Heavy.pm
# once (56µs+7µs) by Bio::Tools::GuessSeqFormat::BEGIN@251 at line 251 of Bio/Tools/GuessSeqFormat.pm
# once (53µs+7µs) by Bio::Roary::Exceptions::CouldntWriteToFile::BEGIN@3 at line 3 of (eval 182)[Exception/Class.pm:179]
# once (53µs+6µs) by Graph::TransitiveClosure::BEGIN@9 at line 9 of Graph/TransitiveClosure.pm
# once (52µs+6µs) by Graph::AdjacencyMap::Light::BEGIN@10 at line 10 of Graph/AdjacencyMap/Light.pm
# once (46µs+6µs) by Graph::AdjacencyMap::Vertex::BEGIN@13 at line 13 of Graph/AdjacencyMap/Vertex.pm
# once (48µs+-48µs) by Bio::RangeI::BEGIN@96 at line 96 of Bio/RangeI.pm
# once (522µs+-522µs) by Bio::Seq::BEGIN@464 at line 464 of Bio/Seq.pm
# once (46µs+-46µs) by Bio::Factory::ObjectBuilderI::BEGIN@98 at line 98 of Bio/Factory/ObjectBuilderI.pm
# once (2.48ms+-2.48ms) by Bio::LocationI::BEGIN@79 at line 79 of Bio/LocationI.pm
# once (1.86ms+-1.86ms) by Bio::Root::Root::BEGIN@5 at line 5 of Bio/Root/Root.pm
# once (61µs+-61µs) by Bio::AnnotationI::BEGIN@120 at line 120 of Bio/AnnotationI.pm
# once (59µs+-59µs) by Bio::Factory::ObjectFactoryI::BEGIN@80 at line 80 of Bio/Factory/ObjectFactoryI.pm
# once (53µs+-53µs) by Bio::PrimarySeqI::BEGIN@126 at line 126 of Bio/PrimarySeqI.pm
# once (56µs+-56µs) by Bio::Location::SplitLocationI::BEGIN@84 at line 84 of Bio/Location/SplitLocationI.pm
# once (3.69ms+-3.69ms) by Bio::PrimarySeq::BEGIN@133 at line 134 of Bio/PrimarySeq.pm
# once (841µs+-841µs) by Bio::Location::Atomic::BEGIN@81 at line 81 of Bio/Location/Atomic.pm
# once (75µs+-75µs) by Bio::IdentifiableI::BEGIN@96 at line 96 of Bio/IdentifiableI.pm
# once (65µs+-65µs) by Bio::Tools::CodonTable::BEGIN@193 at line 193 of Bio/Tools/CodonTable.pm
# once (55µs+-55µs) by Bio::SeqAnalysisParserI::BEGIN@93 at line 93 of Bio/SeqAnalysisParserI.pm
# once (52µs+-52µs) by Bio::Location::CoordinatePolicyI::BEGIN@86 at line 86 of Bio/Location/CoordinatePolicyI.pm
# once (795µs+-795µs) by Bio::SeqI::BEGIN@116 at line 116 of Bio/SeqI.pm
# once (42µs+-42µs) by Bio::FeatureHolderI::BEGIN@98 at line 98 of Bio/FeatureHolderI.pm
# once (66µs+-66µs) by Bio::Root::IO::BEGIN@8 at line 8 of Bio/Root/IO.pm
# once (52µs+-52µs) by Bio::SeqFeatureI::BEGIN@109 at line 109 of Bio/SeqFeatureI.pm
# once (64µs+-64µs) by Bio::Location::FuzzyLocationI::BEGIN@78 at line 78 of Bio/Location/FuzzyLocationI.pm
# once (47µs+-47µs) by Bio::DB::RandomAccessI::BEGIN@68 at line 68 of Bio/DB/RandomAccessI.pm
# once (53µs+-53µs) by Bio::Factory::LocationFactoryI::BEGIN@94 at line 94 of Bio/Factory/LocationFactoryI.pm
# once (261µs+-261µs) by Bio::Factory::SequenceFactoryI::BEGIN@88 at line 88 of Bio/Factory/SequenceFactoryI.pm
# once (319µs+-319µs) by Bio::DB::InMemoryCache::BEGIN@77 at line 77 of Bio/DB/InMemoryCache.pm
# once (69µs+-69µs) by Bio::DescribableI::BEGIN@70 at line 70 of Bio/DescribableI.pm
# once (101µs+-101µs) by Bio::Range::BEGIN@94 at line 94 of Bio/Range.pm
# once (54µs+-54µs) by Bio::AnnotationCollectionI::BEGIN@137 at line 137 of Bio/AnnotationCollectionI.pm
# once (306µs+-306µs) by Bio::Location::WidestCoordPolicy::BEGIN@80 at line 80 of Bio/Location/WidestCoordPolicy.pm
# once (282µs+-282µs) by Bio::DB::SeqI::BEGIN@81 at line 81 of Bio/DB/SeqI.pm
# once (65µs+-65µs) by Bio::Tools::IUPAC::BEGIN@169 at line 169 of Bio/Tools/IUPAC.pm
# once (50µs+-50µs) by Bio::AnnotatableI::BEGIN@86 at line 86 of Bio/AnnotatableI.pm | ||||
59 | 61 | 36µs | my $class = shift; | ||
60 | |||||
61 | 61 | 22µs | return SUCCESS unless @_; | ||
62 | |||||
63 | # List of base classes from which we will inherit %FIELDS. | ||||
64 | 61 | 9µs | my $fields_base; | ||
65 | |||||
66 | 61 | 62µs | my $inheritor = caller(0); | ||
67 | |||||
68 | 61 | 13µs | my @bases; | ||
69 | 61 | 54µs | foreach my $base (@_) { | ||
70 | 90 | 26µs | if ( $inheritor eq $base ) { | ||
71 | warn "Class '$inheritor' tried to inherit from itself\n"; | ||||
72 | } | ||||
73 | |||||
74 | 90 | 1.02ms | 140 | 224µs | next if grep $_->isa($base), ($inheritor, @bases); # spent 224µs making 140 calls to UNIVERSAL::isa, avg 2µs/call |
75 | |||||
76 | # Following blocks help isolate $SIG{__DIE__} changes | ||||
77 | { | ||||
78 | 176 | 30µs | my $sigdie; | ||
79 | { | ||||
80 | 176 | 188µs | local $SIG{__DIE__}; | ||
81 | 88 | 1.54ms | eval "require $base"; # spent 205µs executing statements in 2 string evals (merged)
# spent 172µs executing statements in 2 string evals (merged)
# spent 158µs executing statements in string eval
# spent 145µs executing statements in string eval
# spent 141µs executing statements in 2 string evals (merged)
# spent 135µs executing statements in string eval
# spent 134µs executing statements in 19 string evals (merged)
# spent 131µs executing statements in 2 string evals (merged)
# spent 131µs executing statements in 2 string evals (merged)
# spent 130µs executing statements in 2 string evals (merged)
# spent 128µs executing statements in 15 string evals (merged)
# spent 122µs executing statements in 2 string evals (merged)
# spent 119µs executing statements in string eval
# spent 116µs executing statements in string eval
# spent 116µs executing statements in string eval
# spent 112µs executing statements in string eval
# spent 110µs executing statements in 4 string evals (merged)
# spent 109µs executing statements in string eval
# spent 101µs executing statements in string eval
# spent 101µs executing statements in 2 string evals (merged)
# spent 100µs executing statements in 3 string evals (merged)
# spent 98µs executing statements in 3 string evals (merged)
# spent 98µs executing statements in string eval
# spent 92µs executing statements in string eval
# spent 8µs executing statements in 2 string evals (merged)
# spent 7µs executing statements in 2 string evals (merged)
# spent 7µs executing statements in 3 string evals (merged)
# spent 6µs executing statements in 2 string evals (merged)
# spent 5µs executing statements in 2 string evals (merged)
# spent 4µs executing statements in string eval
# spent 4µs executing statements in string eval
# spent 4µs executing statements in string eval
# spent 3µs executing statements in string eval
# spent 2µs executing statements in string eval
# spent 2µs executing statements in string eval | ||
82 | # Only ignore "Can't locate" errors from our eval require. | ||||
83 | # Other fatal errors (syntax etc) must be reported. | ||||
84 | 88 | 14µs | die if $@ && $@ !~ /^Can't locate .*? at \(eval /; | ||
85 | 88 | 206µs | unless (%{"$base\::"}) { | ||
86 | require Carp; | ||||
87 | local $" = " "; | ||||
88 | Carp::croak(<<ERROR); | ||||
89 | Base class package "$base" is empty. | ||||
90 | (Perhaps you need to 'use' the module which defines that package first, | ||||
91 | or make that module available in \@INC (\@INC contains: @INC). | ||||
92 | ERROR | ||||
93 | } | ||||
94 | 88 | 223µs | $sigdie = $SIG{__DIE__} || undef; | ||
95 | } | ||||
96 | # Make sure a global $SIG{__DIE__} makes it out of the localization. | ||||
97 | 88 | 26µs | $SIG{__DIE__} = $sigdie if defined $sigdie; | ||
98 | } | ||||
99 | 88 | 81µs | push @bases, $base; | ||
100 | |||||
101 | 88 | 334µs | 176 | 549µs | if ( has_fields($base) || has_attr($base) ) { # spent 315µs making 88 calls to base::has_fields, avg 4µs/call
# spent 234µs making 88 calls to base::has_attr, avg 3µs/call |
102 | # No multiple fields inheritance *suck* | ||||
103 | if ($fields_base) { | ||||
104 | require Carp; | ||||
105 | Carp::croak("Can't multiply inherit fields"); | ||||
106 | } else { | ||||
107 | $fields_base = $base; | ||||
108 | } | ||||
109 | } | ||||
110 | } | ||||
111 | # Save this until the end so it's all or nothing if the above loop croaks. | ||||
112 | 61 | 692µs | push @{"$inheritor\::ISA"}, @bases; | ||
113 | |||||
114 | 61 | 328µs | if( defined $fields_base ) { | ||
115 | inherit_fields($inheritor, $fields_base); | ||||
116 | } | ||||
117 | } | ||||
118 | |||||
119 | |||||
120 | sub inherit_fields { | ||||
121 | my($derived, $base) = @_; | ||||
122 | |||||
123 | return SUCCESS unless $base; | ||||
124 | |||||
125 | my $battr = get_attr($base); | ||||
126 | my $dattr = get_attr($derived); | ||||
127 | my $dfields = get_fields($derived); | ||||
128 | my $bfields = get_fields($base); | ||||
129 | |||||
130 | $dattr->[0] = @$battr; | ||||
131 | |||||
132 | if( keys %$dfields ) { | ||||
133 | warn <<"END"; | ||||
134 | $derived is inheriting from $base but already has its own fields! | ||||
135 | This will cause problems. Be sure you use base BEFORE declaring fields. | ||||
136 | END | ||||
137 | |||||
138 | } | ||||
139 | |||||
140 | # Iterate through the base's fields adding all the non-private | ||||
141 | # ones to the derived class. Hang on to the original attribute | ||||
142 | # (Public, Private, etc...) and add Inherited. | ||||
143 | # This is all too complicated to do efficiently with add_fields(). | ||||
144 | while (my($k,$v) = each %$bfields) { | ||||
145 | my $fno; | ||||
146 | if ($fno = $dfields->{$k} and $fno != $v) { | ||||
147 | require Carp; | ||||
148 | Carp::croak ("Inherited fields can't override existing fields"); | ||||
149 | } | ||||
150 | |||||
151 | if( $battr->[$v] & PRIVATE ) { | ||||
152 | $dattr->[$v] = PRIVATE | INHERITED; | ||||
153 | } | ||||
154 | else { | ||||
155 | $dattr->[$v] = INHERITED | $battr->[$v]; | ||||
156 | $dfields->{$k} = $v; | ||||
157 | } | ||||
158 | } | ||||
159 | |||||
160 | foreach my $idx (1..$#{$battr}) { | ||||
161 | next if defined $dattr->[$idx]; | ||||
162 | $dattr->[$idx] = $battr->[$idx] & INHERITED; | ||||
163 | } | ||||
164 | } | ||||
165 | |||||
166 | |||||
167 | 1 | 11µs | 1; | ||
168 | |||||
169 | __END__ |