1 package org.apache.commons.rng.examples.jmh.core.jmh_generated;
2
3 import java.util.List;
4 import java.util.concurrent.atomic.AtomicInteger;
5 import java.util.Collection;
6 import java.util.ArrayList;
7 import java.util.concurrent.TimeUnit;
8 import org.openjdk.jmh.annotations.CompilerControl;
9 import org.openjdk.jmh.runner.InfraControl;
10 import org.openjdk.jmh.infra.ThreadParams;
11 import org.openjdk.jmh.results.BenchmarkTaskResult;
12 import org.openjdk.jmh.results.Result;
13 import org.openjdk.jmh.results.ThroughputResult;
14 import org.openjdk.jmh.results.AverageTimeResult;
15 import org.openjdk.jmh.results.SampleTimeResult;
16 import org.openjdk.jmh.results.SingleShotResult;
17 import org.openjdk.jmh.util.SampleBuffer;
18 import org.openjdk.jmh.annotations.Mode;
19 import org.openjdk.jmh.annotations.Fork;
20 import org.openjdk.jmh.annotations.Measurement;
21 import org.openjdk.jmh.annotations.Threads;
22 import org.openjdk.jmh.annotations.Warmup;
23 import org.openjdk.jmh.annotations.BenchmarkMode;
24 import org.openjdk.jmh.results.RawResults;
25 import org.openjdk.jmh.results.ResultRole;
26 import java.lang.reflect.Field;
27 import org.openjdk.jmh.infra.BenchmarkParams;
28 import org.openjdk.jmh.infra.IterationParams;
29 import org.openjdk.jmh.infra.Blackhole;
30 import org.openjdk.jmh.infra.Control;
31 import org.openjdk.jmh.results.ScalarResult;
32 import org.openjdk.jmh.results.AggregationPolicy;
33 import org.openjdk.jmh.runner.FailureAssistException;
34
35 import org.apache.commons.rng.examples.jmh.core.jmh_generated.FloatingPointGenerationPerformance_jmhType;
36 import org.apache.commons.rng.examples.jmh.core.jmh_generated.FloatingPointGenerationPerformance_LongSource_jmhType;
37 public final class FloatingPointGenerationPerformance_nextFloatUsingBitsToFloat_jmhTest {
38
39 byte p000, p001, p002, p003, p004, p005, p006, p007, p008, p009, p010, p011, p012, p013, p014, p015;
40 byte p016, p017, p018, p019, p020, p021, p022, p023, p024, p025, p026, p027, p028, p029, p030, p031;
41 byte p032, p033, p034, p035, p036, p037, p038, p039, p040, p041, p042, p043, p044, p045, p046, p047;
42 byte p048, p049, p050, p051, p052, p053, p054, p055, p056, p057, p058, p059, p060, p061, p062, p063;
43 byte p064, p065, p066, p067, p068, p069, p070, p071, p072, p073, p074, p075, p076, p077, p078, p079;
44 byte p080, p081, p082, p083, p084, p085, p086, p087, p088, p089, p090, p091, p092, p093, p094, p095;
45 byte p096, p097, p098, p099, p100, p101, p102, p103, p104, p105, p106, p107, p108, p109, p110, p111;
46 byte p112, p113, p114, p115, p116, p117, p118, p119, p120, p121, p122, p123, p124, p125, p126, p127;
47 byte p128, p129, p130, p131, p132, p133, p134, p135, p136, p137, p138, p139, p140, p141, p142, p143;
48 byte p144, p145, p146, p147, p148, p149, p150, p151, p152, p153, p154, p155, p156, p157, p158, p159;
49 byte p160, p161, p162, p163, p164, p165, p166, p167, p168, p169, p170, p171, p172, p173, p174, p175;
50 byte p176, p177, p178, p179, p180, p181, p182, p183, p184, p185, p186, p187, p188, p189, p190, p191;
51 byte p192, p193, p194, p195, p196, p197, p198, p199, p200, p201, p202, p203, p204, p205, p206, p207;
52 byte p208, p209, p210, p211, p212, p213, p214, p215, p216, p217, p218, p219, p220, p221, p222, p223;
53 byte p224, p225, p226, p227, p228, p229, p230, p231, p232, p233, p234, p235, p236, p237, p238, p239;
54 byte p240, p241, p242, p243, p244, p245, p246, p247, p248, p249, p250, p251, p252, p253, p254, p255;
55 int startRndMask;
56 BenchmarkParams benchmarkParams;
57 IterationParams iterationParams;
58 ThreadParams threadParams;
59 Blackhole blackhole;
60 Control notifyControl;
61
62 public BenchmarkTaskResult nextFloatUsingBitsToFloat_Throughput(InfraControl control, ThreadParams threadParams) throws Throwable {
63 this.benchmarkParams = control.benchmarkParams;
64 this.iterationParams = control.iterationParams;
65 this.threadParams = threadParams;
66 this.notifyControl = control.notifyControl;
67 if (this.blackhole == null) {
68 this.blackhole = new Blackhole("Today's password is swordfish. I understand instantiating Blackholes directly is dangerous.");
69 }
70 if (threadParams.getSubgroupIndex() == 0) {
71 RawResults res = new RawResults();
72 FloatingPointGenerationPerformance_jmhType l_floatingpointgenerationperformance0_G = _jmh_tryInit_f_floatingpointgenerationperformance0_G(control);
73 FloatingPointGenerationPerformance_LongSource_jmhType l_longsource1_G = _jmh_tryInit_f_longsource1_G(control);
74
75 control.preSetup();
76
77
78 control.announceWarmupReady();
79 while (control.warmupShouldWait) {
80 blackhole.consume(l_floatingpointgenerationperformance0_G.nextFloatUsingBitsToFloat(l_longsource1_G));
81 res.allOps++;
82 }
83
84 notifyControl.startMeasurement = true;
85 nextFloatUsingBitsToFloat_thrpt_jmhStub(control, res, benchmarkParams, iterationParams, threadParams, blackhole, notifyControl, startRndMask, l_longsource1_G, l_floatingpointgenerationperformance0_G);
86 notifyControl.stopMeasurement = true;
87 control.announceWarmdownReady();
88 try {
89 while (control.warmdownShouldWait) {
90 blackhole.consume(l_floatingpointgenerationperformance0_G.nextFloatUsingBitsToFloat(l_longsource1_G));
91 res.allOps++;
92 }
93 } catch (Throwable e) {
94 if (!(e instanceof InterruptedException)) throw e;
95 }
96 control.preTearDown();
97
98 if (control.isLastIteration()) {
99 synchronized(this.getClass()) {
100 f_longsource1_G = null;
101 }
102 synchronized(this.getClass()) {
103 f_floatingpointgenerationperformance0_G = null;
104 }
105 }
106 res.allOps += res.measuredOps;
107 int batchSize = iterationParams.getBatchSize();
108 int opsPerInv = benchmarkParams.getOpsPerInvocation();
109 res.allOps *= opsPerInv;
110 res.allOps /= batchSize;
111 res.measuredOps *= opsPerInv;
112 res.measuredOps /= batchSize;
113 BenchmarkTaskResult results = new BenchmarkTaskResult((long)res.allOps, (long)res.measuredOps);
114 results.add(new ThroughputResult(ResultRole.PRIMARY, "nextFloatUsingBitsToFloat", res.measuredOps, res.getTime(), benchmarkParams.getTimeUnit()));
115 this.blackhole.evaporate("Yes, I am Stephen Hawking, and know a thing or two about black holes.");
116 return results;
117 } else
118 throw new IllegalStateException("Harness failed to distribute threads among groups properly");
119 }
120
121 public static void nextFloatUsingBitsToFloat_thrpt_jmhStub(InfraControl control, RawResults result, BenchmarkParams benchmarkParams, IterationParams iterationParams, ThreadParams threadParams, Blackhole blackhole, Control notifyControl, int startRndMask, FloatingPointGenerationPerformance_LongSource_jmhType l_longsource1_G, FloatingPointGenerationPerformance_jmhType l_floatingpointgenerationperformance0_G) throws Throwable {
122 long operations = 0;
123 long realTime = 0;
124 result.startTime = System.nanoTime();
125 do {
126 blackhole.consume(l_floatingpointgenerationperformance0_G.nextFloatUsingBitsToFloat(l_longsource1_G));
127 operations++;
128 } while(!control.isDone);
129 result.stopTime = System.nanoTime();
130 result.realTime = realTime;
131 result.measuredOps = operations;
132 }
133
134
135 public BenchmarkTaskResult nextFloatUsingBitsToFloat_AverageTime(InfraControl control, ThreadParams threadParams) throws Throwable {
136 this.benchmarkParams = control.benchmarkParams;
137 this.iterationParams = control.iterationParams;
138 this.threadParams = threadParams;
139 this.notifyControl = control.notifyControl;
140 if (this.blackhole == null) {
141 this.blackhole = new Blackhole("Today's password is swordfish. I understand instantiating Blackholes directly is dangerous.");
142 }
143 if (threadParams.getSubgroupIndex() == 0) {
144 RawResults res = new RawResults();
145 FloatingPointGenerationPerformance_jmhType l_floatingpointgenerationperformance0_G = _jmh_tryInit_f_floatingpointgenerationperformance0_G(control);
146 FloatingPointGenerationPerformance_LongSource_jmhType l_longsource1_G = _jmh_tryInit_f_longsource1_G(control);
147
148 control.preSetup();
149
150
151 control.announceWarmupReady();
152 while (control.warmupShouldWait) {
153 blackhole.consume(l_floatingpointgenerationperformance0_G.nextFloatUsingBitsToFloat(l_longsource1_G));
154 res.allOps++;
155 }
156
157 notifyControl.startMeasurement = true;
158 nextFloatUsingBitsToFloat_avgt_jmhStub(control, res, benchmarkParams, iterationParams, threadParams, blackhole, notifyControl, startRndMask, l_longsource1_G, l_floatingpointgenerationperformance0_G);
159 notifyControl.stopMeasurement = true;
160 control.announceWarmdownReady();
161 try {
162 while (control.warmdownShouldWait) {
163 blackhole.consume(l_floatingpointgenerationperformance0_G.nextFloatUsingBitsToFloat(l_longsource1_G));
164 res.allOps++;
165 }
166 } catch (Throwable e) {
167 if (!(e instanceof InterruptedException)) throw e;
168 }
169 control.preTearDown();
170
171 if (control.isLastIteration()) {
172 synchronized(this.getClass()) {
173 f_longsource1_G = null;
174 }
175 synchronized(this.getClass()) {
176 f_floatingpointgenerationperformance0_G = null;
177 }
178 }
179 res.allOps += res.measuredOps;
180 int batchSize = iterationParams.getBatchSize();
181 int opsPerInv = benchmarkParams.getOpsPerInvocation();
182 res.allOps *= opsPerInv;
183 res.allOps /= batchSize;
184 res.measuredOps *= opsPerInv;
185 res.measuredOps /= batchSize;
186 BenchmarkTaskResult results = new BenchmarkTaskResult((long)res.allOps, (long)res.measuredOps);
187 results.add(new AverageTimeResult(ResultRole.PRIMARY, "nextFloatUsingBitsToFloat", res.measuredOps, res.getTime(), benchmarkParams.getTimeUnit()));
188 this.blackhole.evaporate("Yes, I am Stephen Hawking, and know a thing or two about black holes.");
189 return results;
190 } else
191 throw new IllegalStateException("Harness failed to distribute threads among groups properly");
192 }
193
194 public static void nextFloatUsingBitsToFloat_avgt_jmhStub(InfraControl control, RawResults result, BenchmarkParams benchmarkParams, IterationParams iterationParams, ThreadParams threadParams, Blackhole blackhole, Control notifyControl, int startRndMask, FloatingPointGenerationPerformance_LongSource_jmhType l_longsource1_G, FloatingPointGenerationPerformance_jmhType l_floatingpointgenerationperformance0_G) throws Throwable {
195 long operations = 0;
196 long realTime = 0;
197 result.startTime = System.nanoTime();
198 do {
199 blackhole.consume(l_floatingpointgenerationperformance0_G.nextFloatUsingBitsToFloat(l_longsource1_G));
200 operations++;
201 } while(!control.isDone);
202 result.stopTime = System.nanoTime();
203 result.realTime = realTime;
204 result.measuredOps = operations;
205 }
206
207
208 public BenchmarkTaskResult nextFloatUsingBitsToFloat_SampleTime(InfraControl control, ThreadParams threadParams) throws Throwable {
209 this.benchmarkParams = control.benchmarkParams;
210 this.iterationParams = control.iterationParams;
211 this.threadParams = threadParams;
212 this.notifyControl = control.notifyControl;
213 if (this.blackhole == null) {
214 this.blackhole = new Blackhole("Today's password is swordfish. I understand instantiating Blackholes directly is dangerous.");
215 }
216 if (threadParams.getSubgroupIndex() == 0) {
217 RawResults res = new RawResults();
218 FloatingPointGenerationPerformance_jmhType l_floatingpointgenerationperformance0_G = _jmh_tryInit_f_floatingpointgenerationperformance0_G(control);
219 FloatingPointGenerationPerformance_LongSource_jmhType l_longsource1_G = _jmh_tryInit_f_longsource1_G(control);
220
221 control.preSetup();
222
223
224 control.announceWarmupReady();
225 while (control.warmupShouldWait) {
226 blackhole.consume(l_floatingpointgenerationperformance0_G.nextFloatUsingBitsToFloat(l_longsource1_G));
227 res.allOps++;
228 }
229
230 notifyControl.startMeasurement = true;
231 int targetSamples = (int) (control.getDuration(TimeUnit.MILLISECONDS) * 20);
232 int batchSize = iterationParams.getBatchSize();
233 int opsPerInv = benchmarkParams.getOpsPerInvocation();
234 SampleBuffer buffer = new SampleBuffer();
235 nextFloatUsingBitsToFloat_sample_jmhStub(control, res, benchmarkParams, iterationParams, threadParams, blackhole, notifyControl, startRndMask, buffer, targetSamples, opsPerInv, batchSize, l_longsource1_G, l_floatingpointgenerationperformance0_G);
236 notifyControl.stopMeasurement = true;
237 control.announceWarmdownReady();
238 try {
239 while (control.warmdownShouldWait) {
240 blackhole.consume(l_floatingpointgenerationperformance0_G.nextFloatUsingBitsToFloat(l_longsource1_G));
241 res.allOps++;
242 }
243 } catch (Throwable e) {
244 if (!(e instanceof InterruptedException)) throw e;
245 }
246 control.preTearDown();
247
248 if (control.isLastIteration()) {
249 synchronized(this.getClass()) {
250 f_longsource1_G = null;
251 }
252 synchronized(this.getClass()) {
253 f_floatingpointgenerationperformance0_G = null;
254 }
255 }
256 res.allOps += res.measuredOps * batchSize;
257 res.allOps *= opsPerInv;
258 res.allOps /= batchSize;
259 res.measuredOps *= opsPerInv;
260 BenchmarkTaskResult results = new BenchmarkTaskResult((long)res.allOps, (long)res.measuredOps);
261 results.add(new SampleTimeResult(ResultRole.PRIMARY, "nextFloatUsingBitsToFloat", buffer, benchmarkParams.getTimeUnit()));
262 this.blackhole.evaporate("Yes, I am Stephen Hawking, and know a thing or two about black holes.");
263 return results;
264 } else
265 throw new IllegalStateException("Harness failed to distribute threads among groups properly");
266 }
267
268 public static void nextFloatUsingBitsToFloat_sample_jmhStub(InfraControl control, RawResults result, BenchmarkParams benchmarkParams, IterationParams iterationParams, ThreadParams threadParams, Blackhole blackhole, Control notifyControl, int startRndMask, SampleBuffer buffer, int targetSamples, long opsPerInv, int batchSize, FloatingPointGenerationPerformance_LongSource_jmhType l_longsource1_G, FloatingPointGenerationPerformance_jmhType l_floatingpointgenerationperformance0_G) throws Throwable {
269 long realTime = 0;
270 long operations = 0;
271 int rnd = (int)System.nanoTime();
272 int rndMask = startRndMask;
273 long time = 0;
274 int currentStride = 0;
275 do {
276 rnd = (rnd * 1664525 + 1013904223);
277 boolean sample = (rnd & rndMask) == 0;
278 if (sample) {
279 time = System.nanoTime();
280 }
281 for (int b = 0; b < batchSize; b++) {
282 if (control.volatileSpoiler) return;
283 blackhole.consume(l_floatingpointgenerationperformance0_G.nextFloatUsingBitsToFloat(l_longsource1_G));
284 }
285 if (sample) {
286 buffer.add((System.nanoTime() - time) / opsPerInv);
287 if (currentStride++ > targetSamples) {
288 buffer.half();
289 currentStride = 0;
290 rndMask = (rndMask << 1) + 1;
291 }
292 }
293 operations++;
294 } while(!control.isDone);
295 startRndMask = Math.max(startRndMask, rndMask);
296 result.realTime = realTime;
297 result.measuredOps = operations;
298 }
299
300
301 public BenchmarkTaskResult nextFloatUsingBitsToFloat_SingleShotTime(InfraControl control, ThreadParams threadParams) throws Throwable {
302 this.benchmarkParams = control.benchmarkParams;
303 this.iterationParams = control.iterationParams;
304 this.threadParams = threadParams;
305 this.notifyControl = control.notifyControl;
306 if (this.blackhole == null) {
307 this.blackhole = new Blackhole("Today's password is swordfish. I understand instantiating Blackholes directly is dangerous.");
308 }
309 if (threadParams.getSubgroupIndex() == 0) {
310 FloatingPointGenerationPerformance_jmhType l_floatingpointgenerationperformance0_G = _jmh_tryInit_f_floatingpointgenerationperformance0_G(control);
311 FloatingPointGenerationPerformance_LongSource_jmhType l_longsource1_G = _jmh_tryInit_f_longsource1_G(control);
312
313 control.preSetup();
314
315
316 notifyControl.startMeasurement = true;
317 RawResults res = new RawResults();
318 int batchSize = iterationParams.getBatchSize();
319 nextFloatUsingBitsToFloat_ss_jmhStub(control, res, benchmarkParams, iterationParams, threadParams, blackhole, notifyControl, startRndMask, batchSize, l_longsource1_G, l_floatingpointgenerationperformance0_G);
320 control.preTearDown();
321
322 if (control.isLastIteration()) {
323 synchronized(this.getClass()) {
324 f_longsource1_G = null;
325 }
326 synchronized(this.getClass()) {
327 f_floatingpointgenerationperformance0_G = null;
328 }
329 }
330 int opsPerInv = control.benchmarkParams.getOpsPerInvocation();
331 long totalOps = opsPerInv;
332 BenchmarkTaskResult results = new BenchmarkTaskResult(totalOps, totalOps);
333 results.add(new SingleShotResult(ResultRole.PRIMARY, "nextFloatUsingBitsToFloat", res.getTime(), totalOps, benchmarkParams.getTimeUnit()));
334 this.blackhole.evaporate("Yes, I am Stephen Hawking, and know a thing or two about black holes.");
335 return results;
336 } else
337 throw new IllegalStateException("Harness failed to distribute threads among groups properly");
338 }
339
340 public static void nextFloatUsingBitsToFloat_ss_jmhStub(InfraControl control, RawResults result, BenchmarkParams benchmarkParams, IterationParams iterationParams, ThreadParams threadParams, Blackhole blackhole, Control notifyControl, int startRndMask, int batchSize, FloatingPointGenerationPerformance_LongSource_jmhType l_longsource1_G, FloatingPointGenerationPerformance_jmhType l_floatingpointgenerationperformance0_G) throws Throwable {
341 long realTime = 0;
342 result.startTime = System.nanoTime();
343 for (int b = 0; b < batchSize; b++) {
344 if (control.volatileSpoiler) return;
345 blackhole.consume(l_floatingpointgenerationperformance0_G.nextFloatUsingBitsToFloat(l_longsource1_G));
346 }
347 result.stopTime = System.nanoTime();
348 result.realTime = realTime;
349 }
350
351
352 static volatile FloatingPointGenerationPerformance_jmhType f_floatingpointgenerationperformance0_G;
353
354 FloatingPointGenerationPerformance_jmhType _jmh_tryInit_f_floatingpointgenerationperformance0_G(InfraControl control) throws Throwable {
355 FloatingPointGenerationPerformance_jmhType val = f_floatingpointgenerationperformance0_G;
356 if (val != null) {
357 return val;
358 }
359 synchronized(this.getClass()) {
360 try {
361 if (control.isFailing) throw new FailureAssistException();
362 val = f_floatingpointgenerationperformance0_G;
363 if (val != null) {
364 return val;
365 }
366 val = new FloatingPointGenerationPerformance_jmhType();
367 val.readyTrial = true;
368 f_floatingpointgenerationperformance0_G = val;
369 } catch (Throwable t) {
370 control.isFailing = true;
371 throw t;
372 }
373 }
374 return val;
375 }
376
377 static volatile FloatingPointGenerationPerformance_LongSource_jmhType f_longsource1_G;
378
379 FloatingPointGenerationPerformance_LongSource_jmhType _jmh_tryInit_f_longsource1_G(InfraControl control) throws Throwable {
380 FloatingPointGenerationPerformance_LongSource_jmhType val = f_longsource1_G;
381 if (val != null) {
382 return val;
383 }
384 synchronized(this.getClass()) {
385 try {
386 if (control.isFailing) throw new FailureAssistException();
387 val = f_longsource1_G;
388 if (val != null) {
389 return val;
390 }
391 val = new FloatingPointGenerationPerformance_LongSource_jmhType();
392 val.readyTrial = true;
393 f_longsource1_G = val;
394 } catch (Throwable t) {
395 control.isFailing = true;
396 throw t;
397 }
398 }
399 return val;
400 }
401
402
403 }
404