3 See the NOTICE file distributed with
this work
for additional information
4 regarding copyright ownership.
6 Licensed under the Apache License, Version 2.0 (the
"License");
7 you may not use
this file except in compliance with the License.
8 You may obtain a copy of the License at
12 Unless required by applicable law or agreed to in writing, software
13 distributed under the License is distributed on an
"AS IS" BASIS,
14 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 See the License
for the specific language governing permissions and
16 limitations under the License.
23 Please email comments or questions to the
public Ensembl
24 developers list at <http:
26 Questions may also be sent to the Ensembl help desk at
40 &eprof_start(
'function-a');
42 &eprof_end(
'function-a');
44 &eprof_dump( \*STDERR );
46 # there is an object based set for above as well, for running
47 # multiple concurrent profilers
51 This is an Ensembl profiler as we broke the Perl profilers.
57 package Bio::EnsEMBL::Utils::Eprof;
65 use base qw( Exporter );
68 (
'eprof_start',
'eprof_end',
'eprof_dump',
'eprof_reset' );
75 my $class = ref($proto) || $proto;
76 my $self = bless( {
'_tags' => {} }, $class );
96 if ( !defined($global) ) {
100 $global->start($tag);
118 if ( !defined($global) ) {
128 if ( !defined($global) ) {
return }
145 sub eprof_reset { undef($global) }
160 my ( $self, $fh ) = @_;
163 $self->_tags()->{$a}->total_time()
164 <=> $self->_tags()->{$b}->total_time()
165 } keys %{ $self->_tags() };
167 foreach my $tag (@tags) {
168 my $st = $self->_tags->{$tag};
170 if ( $st->number() == 0 ) { next }
174 if ( $st->number() > 1 ) {
176 $st->total_time_time() -
177 $st->total_time()*$st->total_time()/$st->number();
180 $STD = sprintf(
"%6f",
181 sqrt( $SS/$st->number()/( $st->number() - 1 ) )
186 print( $fh sprintf(
"Eprof: %20s %6f %6f %d %s [%6f,%6f]\n",
187 $st->tag(), $st->total_time(),
188 $st->total_time()/$st->number(), $st->number(),
189 $STD, $st->min_time(),
191 } ## end
foreach my $tag (@tags)
197 Usage : $eprof->start(
'this_tag');
207 my ( $self, $tag ) = @_;
209 if ( !defined($tag) ) {
210 $self->throw(
"No tag, can't start.");
213 if ( !defined( $self->_tags()->{$tag} ) ) {
217 $self->_tags()->{$tag}->push_stack();
223 Usage : $eprof->end(
'this_tag');
233 my ( $self, $tag ) = @_;
235 if ( !defined($tag) ) {
236 $self->throw(
"No tag, can't end.");
239 if ( !defined( $self->_tags()->{$tag} ) ) {
241 sprintf(
"Ending with a nonexistant tag '%s'", $tag ) );
244 $self->_tags->{$tag}->pop_stack();
250 Usage : $obj->_tags($newval)
252 Returns : value of _tags
253 Args : newvalue (optional)
260 return $obj->{
'_tags'};