X-Git-Url: https://git.kernel.dk/?p=fio.git;a=blobdiff_plain;f=eta.c;h=99e59ec51d78d4bac7ff45180f16f3ce9407a7d2;hp=0eca3be0e345ee6c797f1d9f86f1ccbb9f6cd783;hb=02bcaa8c31feb93c61b701d143a7eea3efd2124d;hpb=74939e38e5164682a57cbe2dfdced09b35cd0259 diff --git a/eta.c b/eta.c index 0eca3be0..99e59ec5 100644 --- a/eta.c +++ b/eta.c @@ -172,19 +172,28 @@ 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; + struct thread_data *td; char eta_str[32]; double perc = 0.0; + static unsigned long long prev_io_bytes[2]; + static struct timeval prev_time; + static unsigned int r_rate, w_rate; + unsigned long long io_bytes[2]; + unsigned long mtime; + if (temp_stall_ts || terse_output) return; + if (!prev_io_bytes[0] && !prev_io_bytes[1]) + fill_start_time(&prev_time); + eta_secs = malloc(thread_number * sizeof(int)); memset(eta_secs, 0, thread_number * sizeof(int)); + io_bytes[0] = io_bytes[1] = 0; nr_pending = nr_running = t_rate = m_rate = 0; - for (i = 0; i < thread_number; i++) { - struct thread_data *td = &threads[i]; - + for_each_td(td, i) { if (td->runstate == TD_RUNNING || td->runstate == TD_VERIFYING|| td->runstate == TD_FSYNCING) { nr_running++; @@ -199,6 +208,8 @@ void print_thread_status(void) eta_secs[i] = INT_MAX; check_str_update(td); + io_bytes[0] += td->io_bytes[0]; + io_bytes[1] += td->io_bytes[1]; } if (exitall_on_terminate) @@ -206,7 +217,7 @@ void print_thread_status(void) else eta_sec = 0; - for (i = 0; i < thread_number; i++) { + for_each_td(td, i) { if (exitall_on_terminate) { if (eta_secs[i] < eta_sec) eta_sec = eta_secs[i]; @@ -216,11 +227,21 @@ void print_thread_status(void) } } + free(eta_secs); + if (eta_sec != INT_MAX && elapsed) { perc = (double) elapsed / (double) (elapsed + eta_sec); eta_to_str(eta_str, eta_sec); } + mtime = mtime_since_now(&prev_time); + if (mtime > 1000) { + r_rate = (io_bytes[0] - prev_io_bytes[0]) / mtime; + w_rate = (io_bytes[1] - prev_io_bytes[1]) / mtime; + fio_gettime(&prev_time, NULL); + memcpy(prev_io_bytes, io_bytes, sizeof(io_bytes)); + } + if (!nr_running && !nr_pending) return; @@ -229,11 +250,10 @@ void print_thread_status(void) printf(", commitrate %d/%dKiB/sec", t_rate, m_rate); if (eta_sec != INT_MAX && nr_running) { perc *= 100.0; - printf(": [%s] [%3.2f%% done] [eta %s]", run_str, perc,eta_str); + printf(": [%s] [%3.2f%% done] [%6u/%6u kb/s] [eta %s]", run_str, perc, r_rate, w_rate, eta_str); } printf("\r"); fflush(stdout); - free(eta_secs); } void print_status_init(int thread_number)