Skip to content

Commit

Permalink
Display the completion ETA once we've done at least 20%
Browse files Browse the repository at this point in the history
  • Loading branch information
leonerd committed Aug 22, 2021
1 parent 1b7fd0d commit c234487
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions Porting/bench.pl
Expand Up @@ -1219,8 +1219,9 @@ sub grind_run {
my %fds; # map fds to jobs
my $select = IO::Select->new();

my $njobs = scalar @jobs;
my $donejobs = 0;
my $njobs = scalar @jobs;
my $donejobs = 0;
my $starttime = time();

while (@jobs or $running) {

Expand All @@ -1237,8 +1238,21 @@ sub grind_run {

my ($in, $out, $pid);
$donejobs++;
warn sprintf "Starting %s (%d of %d, %.2f%%)\n",
$id, $donejobs, $njobs, 100 * $donejobs / $njobs if $OPTS{verbose};
if($OPTS{verbose}) {
my $donefrac = $donejobs / $njobs;
my $eta = "";
# Once we've done at least 20% we'll have a good estimate of
# the total runtime, hence ETA
if($donefrac >= 0.2) {
my $now = time();
my $duration = ($now - $starttime) / $donefrac;
my $remaining = ($starttime + $duration) - $now;
$eta = sprintf ", remaining %d:%02d",
$remaining / 60, $remaining % 60;
}
warn sprintf "Starting %s (%d of %d, %.2f%%%s)\n",
$id, $donejobs, $njobs, 100 * $donefrac, $eta;
}
eval { $pid = IPC::Open2::open2($out, $in, $cmd); 1; }
or die "Error: while starting cachegrind subprocess"
." for $id:\n$@";
Expand Down

0 comments on commit c234487

Please sign in to comment.