diff options
author | Dave Chinner <dchinner@redhat.com> | 2018-03-26 21:27:28 -0500 |
---|---|---|
committer | Eric Sandeen <sandeen@redhat.com> | 2018-03-26 21:27:28 -0500 |
commit | 745952887e0ef0a0a5796bc2cffd3da887147ac0 (patch) | |
tree | 4a79833a63d80384edaa182ab55db351958e3292 | |
parent | 12ac6e048a0fbf987820ee613465eecf884a8528 (diff) | |
download | xfsprogs-dev-745952887e0ef0a0a5796bc2cffd3da887147ac0.tar.gz |
xfs_io: fix operation time reporting
CUrrently the 100th/sec units always report zero, such as:
32 MiB, 8192 ops; 0:00:21.00 (1.476 MiB/sec and 377.9260 ops/sec)
^^
This is incorrect. Fix the maths that is wrong by removing all the
unnecesary floating point maths and just using basic integer
division...
Signed-Off-By: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
-rw-r--r-- | libxcmd/input.c | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/libxcmd/input.c b/libxcmd/input.c index 441bb2fbbf..6e7a8c9822 100644 --- a/libxcmd/input.c +++ b/libxcmd/input.c @@ -154,9 +154,10 @@ tdiv(double value, struct timeval tv) return value / ((double)tv.tv_sec + ((double)tv.tv_usec / 1000000.0)); } -#define HOURS(sec) ((sec) / (60 * 60)) -#define MINUTES(sec) (((sec) % (60 * 60)) / 60) -#define SECONDS(sec) ((sec) % 60) +#define HOURS(sec) ((sec) / (60 * 60)) +#define MINUTES(sec) (((sec) % (60 * 60)) / 60) +#define SECONDS(sec) ((sec) % 60) +#define USEC_TO_100THS(usec) ((usec) / 1000 / 10) void timestr( @@ -165,14 +166,12 @@ timestr( size_t size, int format) { - double usec = (double)tv->tv_usec / 1000000.0; - if (format & TERSE_FIXED_TIME) { if (!HOURS(tv->tv_sec)) { snprintf(ts, size, "%u:%02u.%02u", (unsigned int) MINUTES(tv->tv_sec), (unsigned int) SECONDS(tv->tv_sec), - (unsigned int) usec * 100); + (unsigned int) USEC_TO_100THS(tv->tv_usec)); return; } format |= VERBOSE_FIXED_TIME; /* fallback if hours needed */ @@ -183,9 +182,10 @@ timestr( (unsigned int) HOURS(tv->tv_sec), (unsigned int) MINUTES(tv->tv_sec), (unsigned int) SECONDS(tv->tv_sec), - (unsigned int) usec * 100); + (unsigned int) USEC_TO_100THS(tv->tv_usec)); } else { - snprintf(ts, size, "0.%04u sec", (unsigned int) usec * 10000); + snprintf(ts, size, "0.%04u sec", + (unsigned int) tv->tv_usec / 100); } } |