X-Git-Url: https://git.kernel.dk/?p=fio.git;a=blobdiff_plain;f=eta.c;h=766f6509dfe2e3254c97d602e37c5119694a7878;hp=9a9f658b1969bbbc328c87c44913d6ce78b22019;hb=a7ba8c5f4c0f9fe117d529c1ad6686b2070bae51;hpb=5ec10eaad3b09875b91e19a20bbdfa06f2117562 diff --git a/eta.c b/eta.c index 9a9f658b..766f6509 100644 --- a/eta.c +++ b/eta.c @@ -66,13 +66,11 @@ static void check_str_update(struct thread_data *td) /* * Convert seconds to a printable string. */ -static void eta_to_str(char *str, int eta_sec) +static void eta_to_str(char *str, unsigned long eta_sec) { unsigned int d, h, m, s; int disp_hour = 0; - d = h = m = s = 0; - s = eta_sec % 60; eta_sec /= 60; m = eta_sec % 60; @@ -133,8 +131,9 @@ static int thread_eta(struct thread_data *td, unsigned long elapsed) eta_sec = (unsigned long) (elapsed * (1.0 / perc)) - elapsed; - if (td->o.timeout && eta_sec > (td->o.timeout - elapsed)) - eta_sec = td->o.timeout - elapsed; + if (td->o.timeout && + eta_sec > (td->o.timeout + done_secs - elapsed)) + eta_sec = td->o.timeout + done_secs - elapsed; } else if (td->runstate == TD_NOT_CREATED || td->runstate == TD_CREATED || td->runstate == TD_INITIALIZED) { int t_eta = 0, r_eta = 0; @@ -144,10 +143,10 @@ static int thread_eta(struct thread_data *td, unsigned long elapsed) * if given, otherwise assume it'll run at the specified rate. */ if (td->o.timeout) - t_eta = td->o.timeout + td->o.start_delay - elapsed; + t_eta = td->o.timeout + td->o.start_delay; if (td->o.rate) { r_eta = (bytes_total / 1024) / td->o.rate; - r_eta += td->o.start_delay - elapsed; + r_eta += td->o.start_delay; } if (r_eta && t_eta) @@ -184,13 +183,13 @@ static void calc_rate(unsigned long mtime, unsigned long long *io_bytes, void print_thread_status(void) { unsigned long elapsed = mtime_since_genesis() / 1000; - int i, nr_running, nr_pending, t_rate, m_rate, *eta_secs, eta_sec; + int i, nr_running, nr_pending, t_rate, m_rate; int t_iops, m_iops, files_open; struct thread_data *td; char eta_str[128]; double perc = 0.0; unsigned long long io_bytes[2]; - unsigned long rate_time, disp_time, bw_avg_time; + unsigned long rate_time, disp_time, bw_avg_time, *eta_secs, eta_sec; struct timeval now; static unsigned long long rate_io_bytes[2]; @@ -198,6 +197,7 @@ void print_thread_status(void) static struct timeval rate_prev_time, disp_prev_time; static unsigned int rate[2]; static int linelen_last; + static int eta_good; if (temp_stall_ts || terse_output || eta_print == FIO_ETA_NEVER) return; @@ -210,8 +210,8 @@ void print_thread_status(void) if (!disp_io_bytes[0] && !disp_io_bytes[1]) fill_start_time(&disp_prev_time); - eta_secs = malloc(thread_number * sizeof(int)); - memset(eta_secs, 0, thread_number * sizeof(int)); + eta_secs = malloc(thread_number * sizeof(unsigned long)); + memset(eta_secs, 0, thread_number * sizeof(unsigned long)); io_bytes[0] = io_bytes[1] = 0; nr_pending = nr_running = t_rate = m_rate = t_iops = m_iops = 0; @@ -247,13 +247,8 @@ void print_thread_status(void) eta_sec = 0; for_each_td(td, i) { - if (exitall_on_terminate) { - if (eta_secs[i] < eta_sec) - eta_sec = eta_secs[i]; - } else { - if (eta_secs[i] > eta_sec) - eta_sec = eta_secs[i]; - } + if (eta_secs[i] != INT_MAX) + eta_sec += eta_secs[i]; } free(eta_secs); @@ -289,11 +284,19 @@ void print_thread_status(void) else if (m_iops || t_iops) printf(", CR=%d/%d IOPS", t_iops, m_iops); if (eta_sec != INT_MAX && nr_running) { + char perc_str[32]; int ll; - perc *= 100.0; - ll = printf(": [%s] [%3.1f%% done] [%6u/%6u kb/s] [eta %s]", - run_str, perc, rate[0], rate[1], eta_str); + if (!eta_sec && !eta_good) + strcpy(perc_str, "-.-% done"); + else { + eta_good = 1; + perc *= 100.0; + sprintf(perc_str, "%3.1f%% done", perc); + } + + ll = printf(": [%s] [%s] [%6u/%6u kb/s] [eta %s]", + run_str, perc_str, rate[0], rate[1], eta_str); if (ll >= 0 && ll < linelen_last) printf("%*s", linelen_last - ll, ""); linelen_last = ll;