From e592a06b36999bbb30675a4a58d4ff16ed65e555 Mon Sep 17 00:00:00 2001 From: Aaron Carroll Date: Fri, 14 Sep 2007 09:49:41 +0200 Subject: [PATCH] Add ETA output control and interactivity check - Real-time ETA display is only printed if output is to a terminal. - Accordingly, add --eta=always|never|auto option. Signed-off-by: Jens Axboe --- README | 3 +++ eta.c | 5 ++++- fio.h | 10 ++++++++++ init.c | 14 ++++++++++++++ 4 files changed, 31 insertions(+), 1 deletion(-) diff --git a/README b/README index b7fc96b6..f713f737 100644 --- a/README +++ b/README @@ -72,6 +72,9 @@ $ fio --cmdhelp=cmd Print command help, "all" for all of them --showcmd Turn a job file into command line options --readonly Turn on safety read-only checks + --eta=when When ETA estimate should be printed + May be "always", "never" or "auto" + Any parameters following the options will be assumed to be job files, unless they match a job file parameter. You can add as many as you want, diff --git a/eta.c b/eta.c index 625b1f88..22efd33f 100644 --- a/eta.c +++ b/eta.c @@ -198,7 +198,10 @@ void print_thread_status(void) static struct timeval rate_prev_time, disp_prev_time; static unsigned int rate[2]; - if (temp_stall_ts || terse_output) + if (temp_stall_ts || terse_output || eta_print == FIO_ETA_NEVER) + return; + + if (!isatty(STDOUT_FILENO) && (eta_print != FIO_ETA_ALWAYS)) return; if (!rate_io_bytes[0] && !rate_io_bytes[1]) diff --git a/fio.h b/fio.h index 1b392a03..0d57b608 100644 --- a/fio.h +++ b/fio.h @@ -629,6 +629,15 @@ enum { FIO_FSERVICE_RR = 2, }; +/* + * when should interactive ETA output be generated + */ +enum { + FIO_ETA_AUTO, + FIO_ETA_ALWAYS, + FIO_ETA_NEVER, +}; + /* * 30 second per-io_u timeout, with 5 second intervals to avoid resetting * the timer on each queue operation. @@ -663,6 +672,7 @@ extern int temp_stall_ts; extern unsigned long long mlock_size; extern unsigned long page_mask, page_size; extern int read_only; +extern int eta_print; extern struct thread_data *threads; diff --git a/init.c b/init.c index 89c66afa..84cb2d26 100644 --- a/init.c +++ b/init.c @@ -30,6 +30,7 @@ struct thread_data *threads = NULL; int exitall_on_terminate = 0; int terse_output = 0; +int eta_print; unsigned long long mlock_size = 0; FILE *f_out = NULL; FILE *f_err = NULL; @@ -97,6 +98,11 @@ static struct option long_options[FIO_NR_OPTIONS] = { .has_arg = no_argument, .val = 'r', }, + { + .name = "eta", + .has_arg = required_argument, + .val = 'e', + }, { .name = NULL, }, @@ -742,6 +748,8 @@ static void usage(void) printf("\t--help\t\tPrint this page\n"); printf("\t--cmdhelp=cmd\tPrint command help, \"all\" for all of them\n"); printf("\t--showcmd\tTurn a job file into command line options\n"); + printf("\t--eta=when\tWhen ETA estimate should be printed\n"); + printf("\t \tMay be \"always\", \"never\" or \"auto\"\n"); } static int parse_cmd_line(int argc, char *argv[]) @@ -785,6 +793,12 @@ static int parse_cmd_line(int argc, char *argv[]) case 'v': printf("%s\n", fio_version_string); exit(0); + case 'e': + if (!strcmp("always", optarg)) + eta_print = FIO_ETA_ALWAYS; + else if (!strcmp("never", optarg)) + eta_print = FIO_ETA_NEVER; + break; case FIO_GETOPT_JOB: { const char *opt = long_options[lidx].name; char *val = optarg; -- 2.25.1