Speedup verify random fills by 10-15x
Move the pseudo-random helper into lib/rand.c and use that
from the verify populate as well.
Signed-off-by: Jens Axboe <jaxboe@fusionio.com>
diff --git a/lib/rand.c b/lib/rand.c
index cecc4c2..839a6a9 100644
--- a/lib/rand.c
+++ b/lib/rand.c
@@ -34,6 +34,7 @@
*/
#include "rand.h"
+#include "../hash.h"
struct frand_state __fio_rand_state;
@@ -57,3 +58,19 @@
__rand(state);
__rand(state);
}
+
+void fill_random_buf(void *buf, unsigned int len)
+{
+ unsigned long r = __rand(&__fio_rand_state);
+ long *ptr = buf;
+
+ if (sizeof(int) != sizeof(*ptr))
+ r *= (unsigned long) __rand(&__fio_rand_state);
+
+ while ((void *) ptr - buf < len) {
+ *ptr = r;
+ ptr++;
+ r *= GOLDEN_RATIO_PRIME;
+ r >>= 3;
+ }
+}