eta: Fix ETA oddness at crossover points
authorSitsofe Wheeler <sitsofe@yahoo.com>
Sun, 27 Nov 2016 20:44:30 +0000 (20:44 +0000)
committerSitsofe Wheeler <sitsofe@yahoo.com>
Sun, 27 Nov 2016 21:40:26 +0000 (21:40 +0000)
- Avoid generating a NaN (because casting NaN to an integer is
  undefined) due to no work having been done by clamping ETA to the
  timeout in that scenario.
- Fix the ETA spiking just as ramp time finishes by not adding it to the
  ETA calculation when it's over.

Signed-off-by: Sitsofe Wheeler <sitsofe@yahoo.com>
eta.c

diff --git a/eta.c b/eta.c
index fe7b1e0..f39b1fe 100644 (file)
--- a/eta.c
+++ b/eta.c
@@ -225,7 +225,11 @@ static unsigned long thread_eta(struct thread_data *td)
                        }
                }
 
-               eta_sec = (unsigned long) (elapsed * (1.0 / perc)) - elapsed;
+               if (perc == 0.0) {
+                       eta_sec = timeout;
+               } else {
+                       eta_sec = (unsigned long) (elapsed * (1.0 / perc)) - elapsed;
+               }
 
                if (td->o.timeout &&
                    eta_sec > (timeout + done_secs - elapsed))
@@ -247,7 +251,10 @@ static unsigned long thread_eta(struct thread_data *td)
                        uint64_t start_delay = td->o.start_delay;
                        uint64_t ramp_time = td->o.ramp_time;
 
-                       t_eta = __timeout + start_delay + ramp_time;
+                       t_eta = __timeout + start_delay;
+                       if (!td->ramp_time_over) {
+                               t_eta += ramp_time;
+                       }
                        t_eta /= 1000000ULL;
 
                        if ((td->runstate == TD_RAMP) && in_ramp_time(td)) {