From ae5eaf076dc66144d88715740cb15f23880cc55e Mon Sep 17 00:00:00 2001 From: Sitsofe Wheeler Date: Sun, 27 Nov 2016 20:44:30 +0000 Subject: [PATCH] eta: Fix ETA oddness at crossover points - 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 --- eta.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/eta.c b/eta.c index fe7b1e00..f39b1fe7 100644 --- 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)) { -- 2.25.1