Make normal distribution takes deviations as a percentage
authorJens Axboe <axboe@fb.com>
Wed, 8 Apr 2015 17:24:58 +0000 (11:24 -0600)
committerJens Axboe <axboe@fb.com>
Wed, 8 Apr 2015 17:24:58 +0000 (11:24 -0600)
This makes it independent of the address range generated.

Signed-off-by: Jens Axboe <axboe@fb.com>
lib/gauss.c
options.c

index cd8b6e3..5c3203c 100644 (file)
@@ -47,7 +47,9 @@ void gauss_init(struct gauss_state *gs, unsigned long nranges, unsigned int d,
        memset(gs, 0, sizeof(*gs));
        init_rand_seed(&gs->r, seed);
        gs->nranges = nranges;
-       gs->stddev = d;
-       if (gs->stddev > nranges / 2)
-               gs->stddev = nranges / 2;
+       if (d) {
+               gs->stddev = (nranges * 100) / d;
+               if (gs->stddev > nranges / 2)
+                       gs->stddev = nranges / 2;
+       }
 }
index 1857d41..fbb291b 100644 (file)
--- a/options.c
+++ b/options.c
@@ -744,8 +744,13 @@ static int str_random_distribution_cb(void *data, const char *str)
                        return 1;
                }
                td->o.pareto_h.u.f = val;
-       } else
+       } else {
+               if (val <= 0.00 || val >= 100.0) {
+                       log_err("fio: normal deviation out of range (0 < input < 100.0)\n");
+                       return 1;
+               }
                td->o.gauss_dev = val;
+       }
 
        return 0;
 }