Commit 201193a8 authored by Leo Gordon's avatar Leo Gordon
Browse files

bugfix: make sure we pause the timer to avoid accumulating running totals

parents 63f6adcc be7a995a
......@@ -130,18 +130,18 @@ sub life_cycle {
$self->enter_status('FETCH_INPUT');
$partial_stopwatch->restart();
$self->fetch_input;
$job_partial_timing{'FETCH_INPUT'} = $partial_stopwatch->get_elapsed();
$job_partial_timing{'FETCH_INPUT'} = $partial_stopwatch->pause->get_elapsed;
$self->enter_status('RUN');
$partial_stopwatch->restart();
$self->run;
$job_partial_timing{'RUN'} = $partial_stopwatch->get_elapsed();
$job_partial_timing{'RUN'} = $partial_stopwatch->pause->get_elapsed;
if($self->execute_writes) {
$self->enter_status('WRITE_OUTPUT');
$partial_stopwatch->restart();
$self->write_output;
$job_partial_timing{'WRITE_OUTPUT'} = $partial_stopwatch->get_elapsed();
$job_partial_timing{'WRITE_OUTPUT'} = $partial_stopwatch->pause->get_elapsed;
if( $job->autoflow ) {
print STDERR "\njob ".$job->dbID." : AUTOFLOW input->output\n" if($self->debug);
......
......@@ -63,7 +63,7 @@ sub new {
return $self;
}
sub _unit { # only set it once for each timer to avoid messing everything up
sub _unit { # only set it once for each timer to avoid messing everything up
my $self = shift;
$self->{'_unit'} = shift if(@_);
......@@ -84,24 +84,25 @@ sub accumulated {
return $self->{'_accumulated'} || 0;
}
sub continue {
sub continue { # the opposite of pause()
my $self = shift @_;
unless($self->is_counting) { # ignore if it was already running
$self->is_counting(1);
$self->{'_start'} = time() * $self->_unit
}
return $self;
}
sub restart {
my $self = shift @_;
$self->accumulated(0);
$self->continue;
return $self;
return $self->continue;
}
sub get_elapsed { # peek without stopping (in case it was running)
sub get_elapsed { # peek without stopping (in case it was running)
my $self = shift @_;
return ($self->accumulated + $self->is_counting * (time() * $self->_unit - $self->{'_start'}));
......@@ -112,6 +113,8 @@ sub pause {
$self->accumulated( $self->get_elapsed );
$self->is_counting(0);
return $self;
}
1;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment