From e0250c1b666ae4809f0c1ce60b0b1d4bb4f16273 Mon Sep 17 00:00:00 2001 From: david Date: Wed, 11 Feb 2009 18:56:46 +0000 Subject: [PATCH] Change the conditions for printing a timing status update to what I think they were intended to be. We are okay to print if 1. We don't have a completion time estimate yet; or 2. We have passed the last completion time estimate; or 3. The estimated time remaining differs from the last one printed by more than 3 minutes, and the difference accounts for more than 5% of the estimated total time. The problem was that the last printed time remaining was calculated not as difftime(last_est.tv_sec, last_print.tv_sec), but as difftime(last_est.tv_sec, now->tv_sec). In other words it was constantly changing, and at the same rate as the estimated time left (if the scan was progressing at a constant rate). That means that as soon as a completion time estimate was fairly accurate, you would not get any more estimates because the difference in the two times would always be small. --- timing.cc | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/timing.cc b/timing.cc index b279ff419..daa2f6b47 100644 --- a/timing.cc +++ b/timing.cc @@ -513,8 +513,6 @@ bool ScanProgressMeter::printStatsIfNecessary(double perc_done, const struct timeval *now) { struct timeval tvtmp; double time_left_s; - double prev_est_time_left_s; /* Time left as per prev. estimate */ - double change_abs_s; /* absolute value of change */ bool printit = false; if (!now) { @@ -537,19 +535,19 @@ bool ScanProgressMeter::printStatsIfNecessary(double perc_done, if (time_left_s < 30) return false; /* No point in updating when it is virtually finished. */ - /* If we have not printed before, or if our previous ETC has elapsed, print - a new one */ - if (last_print.tv_sec == 0) + if (last_est.tv_sec == 0) { + /* We don't have an estimate yet (probably means a low completion). */ printit = true; - else { - /* If the estimate changed by more than X minutes, and if that - change represents at least X% of the time remaining, print - it. */ - prev_est_time_left_s = difftime(last_est.tv_sec, now->tv_sec); - change_abs_s = ABS(prev_est_time_left_s - time_left_s); - if (prev_est_time_left_s <= 0) - printit = true; - else if (o.debugging || (change_abs_s > 180 && change_abs_s > .05 * MAX(time_left_s, prev_est_time_left_s))) + } else if (TIMEVAL_AFTER(*now, last_est)) { + /* The last estimate we printed has passed. Print a new one. */ + printit = true; + } else { + /* If the estimate changed by more than 3 minutes, and if that change + represents at least 5% of the total time, print it. */ + double prev_est_total_time_s = difftime(last_est.tv_sec, begin.tv_sec); + double prev_est_time_left_s = difftime(last_est.tv_sec, last_print.tv_sec); + double change_abs_s = ABS(prev_est_time_left_s - time_left_s); + if (o.debugging || (change_abs_s > 15 && change_abs_s > .05 * prev_est_total_time_s)) printit = true; }