Add --eta-newline option
For certain situations, it's handy to force a new line in
the ETA output. It allows you to easily track what
happened, without having to do detailed logging.
Signed-off-by: Jens Axboe <axboe@kernel.dk>
diff --git a/eta.c b/eta.c
index 5ef31c6..f90d428 100644
--- a/eta.c
+++ b/eta.c
@@ -422,12 +422,13 @@
je->nr_threads = thread_number;
memcpy(je->run_str, run_str, thread_number * sizeof(char));
-
return 1;
}
void display_thread_status(struct jobs_eta *je)
{
+ static struct timeval disp_eta_new_line;
+ static int eta_new_line_init, eta_new_line_pending;
static int linelen_last;
static int eta_good;
char output[REAL_MAX_JOBS + 512], *p = output;
@@ -439,6 +440,11 @@
eta_to_str(eta_str, je->eta_sec);
}
+ if (eta_new_line_pending) {
+ eta_new_line_pending = 0;
+ p += sprintf(p, "\n");
+ }
+
p += sprintf(p, "Jobs: %d (f=%d)", je->nr_running, je->files_open);
if (je->m_rate || je->t_rate) {
char *tr, *mr;
@@ -492,6 +498,16 @@
p += sprintf(p, "\r");
printf("%s", output);
+
+ if (!eta_new_line_init) {
+ fio_gettime(&disp_eta_new_line, NULL);
+ eta_new_line_init = 1;
+ } else if (eta_new_line &&
+ mtime_since_now(&disp_eta_new_line) > eta_new_line * 1000) {
+ fio_gettime(&disp_eta_new_line, NULL);
+ eta_new_line_pending = 1;
+ }
+
fflush(stdout);
}