Break double loop on end-of-clat percentiles
authorJens Axboe <axboe@kernel.dk>
Thu, 13 Oct 2011 10:00:24 +0000 (12:00 +0200)
committerJens Axboe <axboe@kernel.dk>
Thu, 13 Oct 2011 10:00:24 +0000 (12:00 +0200)
Signed-off-by: Jens Axboe <axboe@kernel.dk>
stat.c

diff --git a/stat.c b/stat.c
index 6377869cbab7b504a7b4f7c59222e39d9151b6c7..83ffd0690afca59cc6d1ff266bd717ff70d9395e 100644 (file)
--- a/stat.c
+++ b/stat.c
@@ -123,7 +123,7 @@ static void show_clat_percentiles(unsigned int *io_u_plat, unsigned long nr,
        unsigned long sum = 0;
        unsigned int len, i, j = 0, minv = -1U, maxv = 0;
        unsigned int *ovals = NULL, oval_len = 0;
        unsigned long sum = 0;
        unsigned int len, i, j = 0, minv = -1U, maxv = 0;
        unsigned int *ovals = NULL, oval_len = 0;
-       int is_last = 0, scale_down;
+       int is_last, scale_down;
 
        len = 0;
        while (len < FIO_IO_U_LIST_MAX_LEN && plist[len].u.f != 0.0)
 
        len = 0;
        while (len < FIO_IO_U_LIST_MAX_LEN && plist[len].u.f != 0.0)
@@ -143,7 +143,8 @@ static void show_clat_percentiles(unsigned int *io_u_plat, unsigned long nr,
        /*
         * Calculate bucket values, note down max and min values
         */
        /*
         * Calculate bucket values, note down max and min values
         */
-       for (i = 0; i < FIO_IO_U_PLAT_NR; i++) {
+       is_last = 0;
+       for (i = 0; i < FIO_IO_U_PLAT_NR && !is_last; i++) {
                sum += io_u_plat[i];
                while (sum >= (plist[j].u.f / 100.0 * nr)) {
                        assert(plist[j].u.f <= 100.0);
                sum += io_u_plat[i];
                while (sum >= (plist[j].u.f / 100.0 * nr)) {
                        assert(plist[j].u.f <= 100.0);
@@ -158,6 +159,11 @@ static void show_clat_percentiles(unsigned int *io_u_plat, unsigned long nr,
                                minv = ovals[j];
                        if (ovals[j] > maxv)
                                maxv = ovals[j];
                                minv = ovals[j];
                        if (ovals[j] > maxv)
                                maxv = ovals[j];
+
+                       is_last = (j == len - 1);
+                       if (is_last)
+                               break;
+
                        j++;
                }
        }
                        j++;
                }
        }