@@ -43,15 +43,18 @@ public class RngPerformanceTest {
43
43
private static final long LOWER_LONG = 1L <<20 ;
44
44
private static final long UPPER_LONG = 1L <<50 ;
45
45
46
+ // any-size generators
46
47
private static final SecureRandom secureRandom = new SecureRandom ();
47
48
private static final Random random = new Random ();
48
49
private static final Rng rng = new Rng ();
50
+
51
+ // pure int generators
49
52
private static final SpRand32 spRand32 = new SpRand32 ();
50
53
private static final Xorshf32 xorshf32 = new Xorshf32 ();
51
- private static final Xorshf32b xorshf32b = new Xorshf32b ();
54
+
55
+ // pure long generators
52
56
private static final LehmerRng64 lehmer64 = new LehmerRng64 ();
53
57
private static final LehmerRng64MH lehmer64MH = new LehmerRng64MH ();
54
- private static final Xorshf64 xorshf64 = new Xorshf64 ();
55
58
private static final SplitMix64 splitMix64 = new SplitMix64 ();
56
59
private static final Xorshift64Star xorshift64Star = new Xorshift64Star ();
57
60
private static final Xorshift128Plus xorshift128Plus = new Xorshift128Plus ();
@@ -82,10 +85,6 @@ private static void testNextInt() {
82
85
xorshf32 .nextInt ();
83
86
}
84
87
LOG .debug ("Xorshf32.nextInt() took " + timer .capture () + " ms" );
85
- for (int i =0 ; i <NCOUNT ; i ++) {
86
- xorshf32b .nextInt ();
87
- }
88
- LOG .debug ("Xorshf32b.nextInt() took " + timer .capture () + " ms" );
89
88
}
90
89
91
90
private static void testNextIntWithUpperBound () {
@@ -112,10 +111,6 @@ private static void testNextIntWithUpperBound() {
112
111
xorshf32 .nextInt (UPPER_INT );
113
112
}
114
113
LOG .debug ("Xorshf32.nextInt(" + UPPER_INT + ") took " + timer .capture () + " ms" );
115
- for (int i =0 ; i <NCOUNT ; i ++) {
116
- xorshf32b .nextInt (UPPER_INT );
117
- }
118
- LOG .debug ("Xorshf32b.nextInt(" + UPPER_INT + ") took " + timer .capture () + " ms" );
119
114
}
120
115
121
116
private static void testNextIntWithLowerUpperBound () {
@@ -144,10 +139,6 @@ private static void testNextIntWithLowerUpperBound() {
144
139
xorshf32 .nextInt (LOWER_INT , UPPER_INT );
145
140
}
146
141
LOG .debug ("Xorshf32.nextInt(" + LOWER_INT + ", " + UPPER_INT + ") took " + timer .capture () + " ms" );
147
- for (int i =0 ; i <NCOUNT ; i ++) {
148
- xorshf32b .nextInt (LOWER_INT , UPPER_INT );
149
- }
150
- LOG .debug ("Xorshf32b.nextInt(" + LOWER_INT + ", " + UPPER_INT + ") took " + timer .capture () + " ms" );
151
142
}
152
143
153
144
private static void testNextLong () {
@@ -174,10 +165,6 @@ private static void testNextLong() {
174
165
lehmer64MH .nextLong ();
175
166
}
176
167
LOG .debug ("LehmerRng64MH.nextLong() took " + timer .capture () + " ms" );
177
- for (int i =0 ; i <NCOUNT ; i ++) {
178
- xorshf64 .nextLong ();
179
- }
180
- LOG .debug ("Xorshf64.nextLong() took " + timer .capture () + " ms" );
181
168
for (int i =0 ; i <NCOUNT ; i ++) {
182
169
splitMix64 .nextLong ();
183
170
}
@@ -202,10 +189,6 @@ private static void testNextLong() {
202
189
203
190
private static void testNextLongWithUpperBound () {
204
191
Timer timer = new Timer ();
205
- for (int i =0 ; i <NCOUNT ; i ++) {
206
- xorshf64 .nextLong (UPPER_LONG );
207
- }
208
- LOG .debug ("Xorshf64.nextLong(" + UPPER_LONG + ") took " + timer .capture () + " ms" );
209
192
for (int i =0 ; i <NCOUNT ; i ++) {
210
193
splitMix64 .nextLong (UPPER_LONG );
211
194
}
@@ -230,10 +213,6 @@ private static void testNextLongWithUpperBound() {
230
213
231
214
private static void testNextLongWithLowerUpperBound () {
232
215
Timer timer = new Timer ();
233
- for (int i =0 ; i <NCOUNT ; i ++) {
234
- xorshf64 .nextLong (LOWER_LONG , UPPER_LONG );
235
- }
236
- LOG .debug ("Xorshf64.nextLong(" + LOWER_LONG + ", " + UPPER_LONG + ") took " + timer .capture () + " ms" );
237
216
for (int i =0 ; i <NCOUNT ; i ++) {
238
217
splitMix64 .nextLong (LOWER_LONG , UPPER_LONG );
239
218
}
0 commit comments