diff options
author | Tao Ma <boyu.mt@taobao.com> | 2011-01-14 09:06:03 +0100 |
---|---|---|
committer | Jens Axboe <jaxboe@fusionio.com> | 2011-01-14 09:06:03 +0100 |
commit | b7e74b0087fe5d687c6a43a01a2e02d60b618ae0 (patch) | |
tree | 03fdf748971e174e7a886840037627c8a862be5b /stats.h | |
parent | 5480f591a58df0e873ab80ba21e7b81b9a6fa0c5 (diff) | |
download | blktrace-b7e74b0087fe5d687c6a43a01a2e02d60b618ae0.tar.gz blktrace-b7e74b0087fe5d687c6a43a01a2e02d60b618ae0.tar.bz2 |
blkiomon: Fix an output error
When we give out some statistics in blkiomon, we don't consider
the situation that the device has no correspoinding action. See
if there is no disk read during the interval, the output in my box is
like:
sizes read (bytes): num 0, min -1, max 0, sum 0, squ 0, avg nan, var nan
With the fix, now it looks like:
sizes read (bytes): num 0, min -1, max 0, sum 0, squ 0, avg 0.0, var 0.0
Cc: Martin Peschke <mpeschke@linux.vnet.ibm.com>
Signed-off-by: Jens Axboe <jaxboe@fusionio.com>
Diffstat (limited to 'stats.h')
-rw-r--r-- | stats.h | 6 |
1 files changed, 6 insertions, 0 deletions
@@ -75,6 +75,9 @@ static inline void minmax_to_be(struct minmax *mm) static inline double minmax_avg(struct minmax *mm) { + if (!mm->num) + return 0; + return (mm->sum / (double)mm->num); } @@ -82,6 +85,9 @@ static inline double minmax_var(struct minmax *mm) { double num = (double)mm->num; + if (!mm->num) + return 0; + return ((mm->sos - ((mm->sum * mm->sum) / num)) / num); } |