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