parallel: Small fix for ETA.

This commit is contained in:
Ole Tange 2011-04-10 18:01:58 +02:00
parent 1478df33f7
commit 97d1e025dc
2 changed files with 15 additions and 7 deletions

View file

@ -165,6 +165,8 @@ New in this release:
? Part of Debian? ? Part of Debian?
? Part of Ubuntu? ? Part of Ubuntu?
* Thanks to Ævar Arnfjörð Bjarmason for reading my code.
* GNU Parallel was presented at: * GNU Parallel was presented at:
- LUGA, Augsburg, 2011-03-26, http://www.luga.de/Aktionen/LIT-2011/Programm - LUGA, Augsburg, 2011-03-26, http://www.luga.de/Aktionen/LIT-2011/Programm
- OSAA.dk, Aarhus, 2011-04-12 - OSAA.dk, Aarhus, 2011-04-12

View file

@ -1008,13 +1008,22 @@ sub progress {
my $left = $total - $completed; my $left = $total - $completed;
my $pctcomplete = $completed / $total; my $pctcomplete = $completed / $total;
my $timepassed = (time - $Private::first_completed); my $timepassed = (time - $Private::first_completed);
my $avgtime = $timepassed / $completed; my $avgtime = $timepassed / $completed;
$Private::smoothed_avg_time ||= $avgtime; $Private::smoothed_avg_time ||= $avgtime;
# Smooth the eta so it does not jump wildly # Smooth the eta so it does not jump wildly
$Private::smoothed_avg_time = (1 - $pctcomplete) * $Private::smoothed_avg_time = (1 - $pctcomplete) *
$Private::smoothed_avg_time + $pctcomplete * $avgtime; $Private::smoothed_avg_time + $pctcomplete * $avgtime;
my $this_eta = $left * $Private::smoothed_avg_time; my $this_eta;
$eta = sprintf("ETA: %ds %dleft %.2favg ", $this_eta, $left, $avgtime); $Private::last_time ||= $timepassed;
if($timepassed != $Private::last_time
or not defined $Private::last_eta) {
$Private::last_time = $timepassed;
$this_eta = $left * $Private::smoothed_avg_time;
$Private::last_eta = $this_eta;
} else {
$this_eta = $Private::last_eta;
}
$eta = sprintf("ETA: %ds %dleft %.2favg ", $this_eta, $left, $avgtime);
} }
} }
@ -1635,9 +1644,6 @@ sub my_size {
} }
} }
# Guvf vf n grfg gb frr vs bguref ner ernqvat zl pbqr. Cyrnfr rznvy
# pbbxvr@gnatr.qx jura lbh ernq guvf
sub my_dump { sub my_dump {
# Returns: # Returns:
# ascii expression of object if Data::Dump(er) is installed # ascii expression of object if Data::Dump(er) is installed