Add ETA output control and interactivity check
authorAaron Carroll <aaronc@cse.unsw.edu.au>
Fri, 14 Sep 2007 07:49:41 +0000 (09:49 +0200)
committerJens Axboe <jens.axboe@oracle.com>
Fri, 14 Sep 2007 07:49:41 +0000 (09:49 +0200)
 - 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 <jens.axboe@oracle.com>
README
eta.c
fio.h
init.c

diff --git a/README b/README
index b7fc96b6888d1032bf04cbbb5f8c5f309fa18e7c..f713f73793d1ac321e098576a38dcc34e610b479 100644 (file)
--- 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 625b1f885e9899ea1e4d49639d73c14dcac6ec48..22efd33f2a67eea8124db55e7f4ede9aa0f2349b 100644 (file)
--- 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 1b392a0372b0ddbe60984eefc1cc09b60180ffc4..0d57b608c3a29d49f0c8e8008b5c78388a73d110 100644 (file)
--- 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 89c66afa0e1b8b439ce5a534f76e5d83183431ce..84cb2d261251062a50cf4a1a6c875e4cd87edb97 100644 (file)
--- 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;