Add iops rate to ETA display
[fio.git] / fio.h
diff --git a/fio.h b/fio.h
index 9222c051651408bfcdb811883884afced52dc49a..771df35412ea787382b5963086fc9d6466ddf56d 100644 (file)
--- a/fio.h
+++ b/fio.h
@@ -332,12 +332,10 @@ struct thread_data {
 
        struct timeval start;   /* start of this loop */
        struct timeval epoch;   /* time job was started */
-       struct timeval rw_end[2];
        struct timeval last_issue;
        struct timeval tv_cache;
        unsigned int tv_cache_nr;
        unsigned int tv_cache_mask;
-       unsigned int rw_end_set[2];
        unsigned int ramp_time_over;
 
        /*
@@ -553,39 +551,6 @@ extern int load_blktrace(struct thread_data *, const char *);
        }       \
 } while (0)
 
-static inline void fio_file_reset(struct fio_file *f)
-{
-       f->last_free_lookup = 0;
-       f->last_pos = f->file_offset;
-       if (f->file_map)
-               memset(f->file_map, 0, f->num_maps * sizeof(int));
-}
-
-static inline void clear_error(struct thread_data *td)
-{
-       td->error = 0;
-       td->verror[0] = '\0';
-}
-
-#ifdef FIO_INC_DEBUG
-static inline void dprint_io_u(struct io_u *io_u, const char *p)
-{
-       struct fio_file *f = io_u->file;
-
-       dprint(FD_IO, "%s: io_u %p: off=%llu/len=%lu/ddir=%d", p, io_u,
-                                       (unsigned long long) io_u->offset,
-                                       io_u->buflen, io_u->ddir);
-       if (fio_debug & (1 << FD_IO)) {
-               if (f)
-                       log_info("/%s", f->file_name);
-
-               log_info("\n");
-       }
-}
-#else
-#define dprint_io_u(io_u, p)
-#endif
-
 static inline int fio_fill_issue_time(struct thread_data *td)
 {
        if (td->o.read_iolog_file ||
@@ -595,4 +560,47 @@ static inline int fio_fill_issue_time(struct thread_data *td)
        return 0;
 }
 
+/*
+ * Cheesy number->string conversion, complete with carry rounding error.
+ */
+static inline char *num2str(unsigned long num, int maxlen, int base, int pow2)
+{
+       char postfix[] = { ' ', 'K', 'M', 'G', 'P', 'E' };
+       unsigned int thousand;
+       char *buf;
+       int i;
+
+       if (pow2)
+               thousand = 1024;
+       else
+               thousand = 1000;
+
+       buf = malloc(128);
+
+       for (i = 0; base > 1; i++)
+               base /= thousand;
+
+       do {
+               int len, carry = 0;
+
+               len = sprintf(buf, "%'lu", num);
+               if (len <= maxlen) {
+                       if (i >= 1) {
+                               buf[len] = postfix[i];
+                               buf[len + 1] = '\0';
+                       }
+                       return buf;
+               }
+
+               if ((num % thousand) >= (thousand / 2))
+                       carry = 1;
+
+               num /= thousand;
+               num += carry;
+               i++;
+       } while (i <= 5);
+
+       return buf;
+}
+
 #endif