From c5f6427a6fb2a50be3d6736e8bb64bbab30488fe Mon Sep 17 00:00:00 2001 From: David Renshaw Date: Wed, 25 Jun 2014 19:31:08 -0400 Subject: [PATCH] switch to Xorshift generator --- .../java/org/capnproto/benchmark/Common.java | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/benchmark/src/main/java/org/capnproto/benchmark/Common.java b/benchmark/src/main/java/org/capnproto/benchmark/Common.java index 6e7c7a5..21211c9 100644 --- a/benchmark/src/main/java/org/capnproto/benchmark/Common.java +++ b/benchmark/src/main/java/org/capnproto/benchmark/Common.java @@ -2,17 +2,18 @@ package org.capnproto.benchmark; public class Common { public static class FastRand { - public static final int a = 1664525; - public static final int c = 1013904223; - public int state; - - public FastRand() { - this.state = 1013904223; - } + public int x = 0x1d2acd47; + public int y = 0x58ca3e14; + public int z = 0xf563f232; + public int w = 0x0bc76199; public int nextInt() { - this.state = this.a * this.state + c; - return this.state; + int tmp = this.x ^ (this.x << 11); + this.x = this.y; + this.y = this.z; + this.z = this.w; + this.w = this.w ^ (this.w >> 19) ^ tmp ^ (tmp >> 8); + return this.w; } public int nextLessThan(int range) {