[PATCH] Add ETA output control and interactivity check

From: Aaron Carroll <aaronc_at_cse.unsw.edu.au>
Date: Fri, 14 Sep 2007 17:47:02 +1000

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.

diff --git a/README b/README
index b7fc96b..f713f73 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 625b1f8..22efd33 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 1b392a0..0d57b60 100644
--- a/fio.h
+++ b/fio.h
@@ -630,6 +630,15 @@ enum {
 };
 
 /*
+ * 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 89c66af..84cb2d2 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;
@@ -98,6 +99,11 @@ static struct option long_options[FIO_NR_OPTIONS] = {
                 .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;
Received on Fri Sep 14 2007 - 09:47:02 CEST

This archive was generated by hypermail 2.2.0 : Fri Sep 14 2007 - 10:00:01 CEST