1 package org.apache.commons.rng.examples.jmh.sampling.distribution.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.sampling.distribution.jmh_generated.EnumeratedDistributionSamplersPerformance_DirichletDistributionSources_jmhType;
36 import org.apache.commons.rng.examples.jmh.sampling.distribution.jmh_generated.EnumeratedDistributionSamplersPerformance_jmhType;
37 public final class EnumeratedDistributionSamplersPerformance_singleSampleDirichlet_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 singleSampleDirichlet_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 EnumeratedDistributionSamplersPerformance_jmhType l_enumerateddistributionsamplersperformance0_G = _jmh_tryInit_f_enumerateddistributionsamplersperformance0_G(control);
73 EnumeratedDistributionSamplersPerformance_DirichletDistributionSources_jmhType l_dirichletdistributionsources1_G = _jmh_tryInit_f_dirichletdistributionsources1_G(control);
74
75 control.preSetup();
76 if (EnumeratedDistributionSamplersPerformance_DirichletDistributionSources_jmhType.setupIterationMutexUpdater.compareAndSet(l_dirichletdistributionsources1_G, 0, 1)) {
77 try {
78 if (control.isFailing) throw new FailureAssistException();
79 if (!l_dirichletdistributionsources1_G.readyIteration) {
80 l_dirichletdistributionsources1_G.setup();
81 l_dirichletdistributionsources1_G.readyIteration = true;
82 }
83 } catch (Throwable t) {
84 control.isFailing = true;
85 throw t;
86 } finally {
87 EnumeratedDistributionSamplersPerformance_DirichletDistributionSources_jmhType.setupIterationMutexUpdater.set(l_dirichletdistributionsources1_G, 0);
88 }
89 } else {
90 while (EnumeratedDistributionSamplersPerformance_DirichletDistributionSources_jmhType.setupIterationMutexUpdater.get(l_dirichletdistributionsources1_G) == 1) {
91 if (control.isFailing) throw new FailureAssistException();
92 if (Thread.interrupted()) throw new InterruptedException();
93 }
94 }
95
96
97 control.announceWarmupReady();
98 while (control.warmupShouldWait) {
99 blackhole.consume(l_enumerateddistributionsamplersperformance0_G.singleSampleDirichlet(l_dirichletdistributionsources1_G));
100 if (control.shouldYield) Thread.yield();
101 res.allOps++;
102 }
103
104 notifyControl.startMeasurement = true;
105 singleSampleDirichlet_thrpt_jmhStub(control, res, benchmarkParams, iterationParams, threadParams, blackhole, notifyControl, startRndMask, l_dirichletdistributionsources1_G, l_enumerateddistributionsamplersperformance0_G);
106 notifyControl.stopMeasurement = true;
107 control.announceWarmdownReady();
108 try {
109 while (control.warmdownShouldWait) {
110 blackhole.consume(l_enumerateddistributionsamplersperformance0_G.singleSampleDirichlet(l_dirichletdistributionsources1_G));
111 if (control.shouldYield) Thread.yield();
112 res.allOps++;
113 }
114 } catch (Throwable e) {
115 if (!(e instanceof InterruptedException)) throw e;
116 }
117 control.preTearDown();
118 if (EnumeratedDistributionSamplersPerformance_DirichletDistributionSources_jmhType.tearIterationMutexUpdater.compareAndSet(l_dirichletdistributionsources1_G, 0, 1)) {
119 try {
120 if (control.isFailing) throw new FailureAssistException();
121 if (l_dirichletdistributionsources1_G.readyIteration) {
122 l_dirichletdistributionsources1_G.readyIteration = false;
123 }
124 } catch (Throwable t) {
125 control.isFailing = true;
126 throw t;
127 } finally {
128 EnumeratedDistributionSamplersPerformance_DirichletDistributionSources_jmhType.tearIterationMutexUpdater.set(l_dirichletdistributionsources1_G, 0);
129 }
130 } else {
131 while (EnumeratedDistributionSamplersPerformance_DirichletDistributionSources_jmhType.tearIterationMutexUpdater.get(l_dirichletdistributionsources1_G) == 1) {
132 if (control.isFailing) throw new FailureAssistException();
133 if (Thread.interrupted()) throw new InterruptedException();
134 }
135 }
136
137 if (control.isLastIteration()) {
138 if (EnumeratedDistributionSamplersPerformance_DirichletDistributionSources_jmhType.tearTrialMutexUpdater.compareAndSet(l_dirichletdistributionsources1_G, 0, 1)) {
139 try {
140 if (control.isFailing) throw new FailureAssistException();
141 if (l_dirichletdistributionsources1_G.readyTrial) {
142 l_dirichletdistributionsources1_G.readyTrial = false;
143 }
144 } catch (Throwable t) {
145 control.isFailing = true;
146 throw t;
147 } finally {
148 EnumeratedDistributionSamplersPerformance_DirichletDistributionSources_jmhType.tearTrialMutexUpdater.set(l_dirichletdistributionsources1_G, 0);
149 }
150 } else {
151 long l_dirichletdistributionsources1_G_backoff = 1;
152 while (EnumeratedDistributionSamplersPerformance_DirichletDistributionSources_jmhType.tearTrialMutexUpdater.get(l_dirichletdistributionsources1_G) == 1) {
153 TimeUnit.MILLISECONDS.sleep(l_dirichletdistributionsources1_G_backoff);
154 l_dirichletdistributionsources1_G_backoff = Math.max(1024, l_dirichletdistributionsources1_G_backoff * 2);
155 if (control.isFailing) throw new FailureAssistException();
156 if (Thread.interrupted()) throw new InterruptedException();
157 }
158 }
159 synchronized(this.getClass()) {
160 f_dirichletdistributionsources1_G = null;
161 }
162 synchronized(this.getClass()) {
163 f_enumerateddistributionsamplersperformance0_G = null;
164 }
165 }
166 res.allOps += res.measuredOps;
167 int batchSize = iterationParams.getBatchSize();
168 int opsPerInv = benchmarkParams.getOpsPerInvocation();
169 res.allOps *= opsPerInv;
170 res.allOps /= batchSize;
171 res.measuredOps *= opsPerInv;
172 res.measuredOps /= batchSize;
173 BenchmarkTaskResult results = new BenchmarkTaskResult((long)res.allOps, (long)res.measuredOps);
174 results.add(new ThroughputResult(ResultRole.PRIMARY, "singleSampleDirichlet", res.measuredOps, res.getTime(), benchmarkParams.getTimeUnit()));
175 this.blackhole.evaporate("Yes, I am Stephen Hawking, and know a thing or two about black holes.");
176 return results;
177 } else
178 throw new IllegalStateException("Harness failed to distribute threads among groups properly");
179 }
180
181 public static void singleSampleDirichlet_thrpt_jmhStub(InfraControl control, RawResults result, BenchmarkParams benchmarkParams, IterationParams iterationParams, ThreadParams threadParams, Blackhole blackhole, Control notifyControl, int startRndMask, EnumeratedDistributionSamplersPerformance_DirichletDistributionSources_jmhType l_dirichletdistributionsources1_G, EnumeratedDistributionSamplersPerformance_jmhType l_enumerateddistributionsamplersperformance0_G) throws Throwable {
182 long operations = 0;
183 long realTime = 0;
184 result.startTime = System.nanoTime();
185 do {
186 blackhole.consume(l_enumerateddistributionsamplersperformance0_G.singleSampleDirichlet(l_dirichletdistributionsources1_G));
187 operations++;
188 } while(!control.isDone);
189 result.stopTime = System.nanoTime();
190 result.realTime = realTime;
191 result.measuredOps = operations;
192 }
193
194
195 public BenchmarkTaskResult singleSampleDirichlet_AverageTime(InfraControl control, ThreadParams threadParams) throws Throwable {
196 this.benchmarkParams = control.benchmarkParams;
197 this.iterationParams = control.iterationParams;
198 this.threadParams = threadParams;
199 this.notifyControl = control.notifyControl;
200 if (this.blackhole == null) {
201 this.blackhole = new Blackhole("Today's password is swordfish. I understand instantiating Blackholes directly is dangerous.");
202 }
203 if (threadParams.getSubgroupIndex() == 0) {
204 RawResults res = new RawResults();
205 EnumeratedDistributionSamplersPerformance_jmhType l_enumerateddistributionsamplersperformance0_G = _jmh_tryInit_f_enumerateddistributionsamplersperformance0_G(control);
206 EnumeratedDistributionSamplersPerformance_DirichletDistributionSources_jmhType l_dirichletdistributionsources1_G = _jmh_tryInit_f_dirichletdistributionsources1_G(control);
207
208 control.preSetup();
209 if (EnumeratedDistributionSamplersPerformance_DirichletDistributionSources_jmhType.setupIterationMutexUpdater.compareAndSet(l_dirichletdistributionsources1_G, 0, 1)) {
210 try {
211 if (control.isFailing) throw new FailureAssistException();
212 if (!l_dirichletdistributionsources1_G.readyIteration) {
213 l_dirichletdistributionsources1_G.setup();
214 l_dirichletdistributionsources1_G.readyIteration = true;
215 }
216 } catch (Throwable t) {
217 control.isFailing = true;
218 throw t;
219 } finally {
220 EnumeratedDistributionSamplersPerformance_DirichletDistributionSources_jmhType.setupIterationMutexUpdater.set(l_dirichletdistributionsources1_G, 0);
221 }
222 } else {
223 while (EnumeratedDistributionSamplersPerformance_DirichletDistributionSources_jmhType.setupIterationMutexUpdater.get(l_dirichletdistributionsources1_G) == 1) {
224 if (control.isFailing) throw new FailureAssistException();
225 if (Thread.interrupted()) throw new InterruptedException();
226 }
227 }
228
229
230 control.announceWarmupReady();
231 while (control.warmupShouldWait) {
232 blackhole.consume(l_enumerateddistributionsamplersperformance0_G.singleSampleDirichlet(l_dirichletdistributionsources1_G));
233 if (control.shouldYield) Thread.yield();
234 res.allOps++;
235 }
236
237 notifyControl.startMeasurement = true;
238 singleSampleDirichlet_avgt_jmhStub(control, res, benchmarkParams, iterationParams, threadParams, blackhole, notifyControl, startRndMask, l_dirichletdistributionsources1_G, l_enumerateddistributionsamplersperformance0_G);
239 notifyControl.stopMeasurement = true;
240 control.announceWarmdownReady();
241 try {
242 while (control.warmdownShouldWait) {
243 blackhole.consume(l_enumerateddistributionsamplersperformance0_G.singleSampleDirichlet(l_dirichletdistributionsources1_G));
244 if (control.shouldYield) Thread.yield();
245 res.allOps++;
246 }
247 } catch (Throwable e) {
248 if (!(e instanceof InterruptedException)) throw e;
249 }
250 control.preTearDown();
251 if (EnumeratedDistributionSamplersPerformance_DirichletDistributionSources_jmhType.tearIterationMutexUpdater.compareAndSet(l_dirichletdistributionsources1_G, 0, 1)) {
252 try {
253 if (control.isFailing) throw new FailureAssistException();
254 if (l_dirichletdistributionsources1_G.readyIteration) {
255 l_dirichletdistributionsources1_G.readyIteration = false;
256 }
257 } catch (Throwable t) {
258 control.isFailing = true;
259 throw t;
260 } finally {
261 EnumeratedDistributionSamplersPerformance_DirichletDistributionSources_jmhType.tearIterationMutexUpdater.set(l_dirichletdistributionsources1_G, 0);
262 }
263 } else {
264 while (EnumeratedDistributionSamplersPerformance_DirichletDistributionSources_jmhType.tearIterationMutexUpdater.get(l_dirichletdistributionsources1_G) == 1) {
265 if (control.isFailing) throw new FailureAssistException();
266 if (Thread.interrupted()) throw new InterruptedException();
267 }
268 }
269
270 if (control.isLastIteration()) {
271 if (EnumeratedDistributionSamplersPerformance_DirichletDistributionSources_jmhType.tearTrialMutexUpdater.compareAndSet(l_dirichletdistributionsources1_G, 0, 1)) {
272 try {
273 if (control.isFailing) throw new FailureAssistException();
274 if (l_dirichletdistributionsources1_G.readyTrial) {
275 l_dirichletdistributionsources1_G.readyTrial = false;
276 }
277 } catch (Throwable t) {
278 control.isFailing = true;
279 throw t;
280 } finally {
281 EnumeratedDistributionSamplersPerformance_DirichletDistributionSources_jmhType.tearTrialMutexUpdater.set(l_dirichletdistributionsources1_G, 0);
282 }
283 } else {
284 long l_dirichletdistributionsources1_G_backoff = 1;
285 while (EnumeratedDistributionSamplersPerformance_DirichletDistributionSources_jmhType.tearTrialMutexUpdater.get(l_dirichletdistributionsources1_G) == 1) {
286 TimeUnit.MILLISECONDS.sleep(l_dirichletdistributionsources1_G_backoff);
287 l_dirichletdistributionsources1_G_backoff = Math.max(1024, l_dirichletdistributionsources1_G_backoff * 2);
288 if (control.isFailing) throw new FailureAssistException();
289 if (Thread.interrupted()) throw new InterruptedException();
290 }
291 }
292 synchronized(this.getClass()) {
293 f_dirichletdistributionsources1_G = null;
294 }
295 synchronized(this.getClass()) {
296 f_enumerateddistributionsamplersperformance0_G = null;
297 }
298 }
299 res.allOps += res.measuredOps;
300 int batchSize = iterationParams.getBatchSize();
301 int opsPerInv = benchmarkParams.getOpsPerInvocation();
302 res.allOps *= opsPerInv;
303 res.allOps /= batchSize;
304 res.measuredOps *= opsPerInv;
305 res.measuredOps /= batchSize;
306 BenchmarkTaskResult results = new BenchmarkTaskResult((long)res.allOps, (long)res.measuredOps);
307 results.add(new AverageTimeResult(ResultRole.PRIMARY, "singleSampleDirichlet", res.measuredOps, res.getTime(), benchmarkParams.getTimeUnit()));
308 this.blackhole.evaporate("Yes, I am Stephen Hawking, and know a thing or two about black holes.");
309 return results;
310 } else
311 throw new IllegalStateException("Harness failed to distribute threads among groups properly");
312 }
313
314 public static void singleSampleDirichlet_avgt_jmhStub(InfraControl control, RawResults result, BenchmarkParams benchmarkParams, IterationParams iterationParams, ThreadParams threadParams, Blackhole blackhole, Control notifyControl, int startRndMask, EnumeratedDistributionSamplersPerformance_DirichletDistributionSources_jmhType l_dirichletdistributionsources1_G, EnumeratedDistributionSamplersPerformance_jmhType l_enumerateddistributionsamplersperformance0_G) throws Throwable {
315 long operations = 0;
316 long realTime = 0;
317 result.startTime = System.nanoTime();
318 do {
319 blackhole.consume(l_enumerateddistributionsamplersperformance0_G.singleSampleDirichlet(l_dirichletdistributionsources1_G));
320 operations++;
321 } while(!control.isDone);
322 result.stopTime = System.nanoTime();
323 result.realTime = realTime;
324 result.measuredOps = operations;
325 }
326
327
328 public BenchmarkTaskResult singleSampleDirichlet_SampleTime(InfraControl control, ThreadParams threadParams) throws Throwable {
329 this.benchmarkParams = control.benchmarkParams;
330 this.iterationParams = control.iterationParams;
331 this.threadParams = threadParams;
332 this.notifyControl = control.notifyControl;
333 if (this.blackhole == null) {
334 this.blackhole = new Blackhole("Today's password is swordfish. I understand instantiating Blackholes directly is dangerous.");
335 }
336 if (threadParams.getSubgroupIndex() == 0) {
337 RawResults res = new RawResults();
338 EnumeratedDistributionSamplersPerformance_jmhType l_enumerateddistributionsamplersperformance0_G = _jmh_tryInit_f_enumerateddistributionsamplersperformance0_G(control);
339 EnumeratedDistributionSamplersPerformance_DirichletDistributionSources_jmhType l_dirichletdistributionsources1_G = _jmh_tryInit_f_dirichletdistributionsources1_G(control);
340
341 control.preSetup();
342 if (EnumeratedDistributionSamplersPerformance_DirichletDistributionSources_jmhType.setupIterationMutexUpdater.compareAndSet(l_dirichletdistributionsources1_G, 0, 1)) {
343 try {
344 if (control.isFailing) throw new FailureAssistException();
345 if (!l_dirichletdistributionsources1_G.readyIteration) {
346 l_dirichletdistributionsources1_G.setup();
347 l_dirichletdistributionsources1_G.readyIteration = true;
348 }
349 } catch (Throwable t) {
350 control.isFailing = true;
351 throw t;
352 } finally {
353 EnumeratedDistributionSamplersPerformance_DirichletDistributionSources_jmhType.setupIterationMutexUpdater.set(l_dirichletdistributionsources1_G, 0);
354 }
355 } else {
356 while (EnumeratedDistributionSamplersPerformance_DirichletDistributionSources_jmhType.setupIterationMutexUpdater.get(l_dirichletdistributionsources1_G) == 1) {
357 if (control.isFailing) throw new FailureAssistException();
358 if (Thread.interrupted()) throw new InterruptedException();
359 }
360 }
361
362
363 control.announceWarmupReady();
364 while (control.warmupShouldWait) {
365 blackhole.consume(l_enumerateddistributionsamplersperformance0_G.singleSampleDirichlet(l_dirichletdistributionsources1_G));
366 if (control.shouldYield) Thread.yield();
367 res.allOps++;
368 }
369
370 notifyControl.startMeasurement = true;
371 int targetSamples = (int) (control.getDuration(TimeUnit.MILLISECONDS) * 20);
372 int batchSize = iterationParams.getBatchSize();
373 int opsPerInv = benchmarkParams.getOpsPerInvocation();
374 SampleBuffer buffer = new SampleBuffer();
375 singleSampleDirichlet_sample_jmhStub(control, res, benchmarkParams, iterationParams, threadParams, blackhole, notifyControl, startRndMask, buffer, targetSamples, opsPerInv, batchSize, l_dirichletdistributionsources1_G, l_enumerateddistributionsamplersperformance0_G);
376 notifyControl.stopMeasurement = true;
377 control.announceWarmdownReady();
378 try {
379 while (control.warmdownShouldWait) {
380 blackhole.consume(l_enumerateddistributionsamplersperformance0_G.singleSampleDirichlet(l_dirichletdistributionsources1_G));
381 if (control.shouldYield) Thread.yield();
382 res.allOps++;
383 }
384 } catch (Throwable e) {
385 if (!(e instanceof InterruptedException)) throw e;
386 }
387 control.preTearDown();
388 if (EnumeratedDistributionSamplersPerformance_DirichletDistributionSources_jmhType.tearIterationMutexUpdater.compareAndSet(l_dirichletdistributionsources1_G, 0, 1)) {
389 try {
390 if (control.isFailing) throw new FailureAssistException();
391 if (l_dirichletdistributionsources1_G.readyIteration) {
392 l_dirichletdistributionsources1_G.readyIteration = false;
393 }
394 } catch (Throwable t) {
395 control.isFailing = true;
396 throw t;
397 } finally {
398 EnumeratedDistributionSamplersPerformance_DirichletDistributionSources_jmhType.tearIterationMutexUpdater.set(l_dirichletdistributionsources1_G, 0);
399 }
400 } else {
401 while (EnumeratedDistributionSamplersPerformance_DirichletDistributionSources_jmhType.tearIterationMutexUpdater.get(l_dirichletdistributionsources1_G) == 1) {
402 if (control.isFailing) throw new FailureAssistException();
403 if (Thread.interrupted()) throw new InterruptedException();
404 }
405 }
406
407 if (control.isLastIteration()) {
408 if (EnumeratedDistributionSamplersPerformance_DirichletDistributionSources_jmhType.tearTrialMutexUpdater.compareAndSet(l_dirichletdistributionsources1_G, 0, 1)) {
409 try {
410 if (control.isFailing) throw new FailureAssistException();
411 if (l_dirichletdistributionsources1_G.readyTrial) {
412 l_dirichletdistributionsources1_G.readyTrial = false;
413 }
414 } catch (Throwable t) {
415 control.isFailing = true;
416 throw t;
417 } finally {
418 EnumeratedDistributionSamplersPerformance_DirichletDistributionSources_jmhType.tearTrialMutexUpdater.set(l_dirichletdistributionsources1_G, 0);
419 }
420 } else {
421 long l_dirichletdistributionsources1_G_backoff = 1;
422 while (EnumeratedDistributionSamplersPerformance_DirichletDistributionSources_jmhType.tearTrialMutexUpdater.get(l_dirichletdistributionsources1_G) == 1) {
423 TimeUnit.MILLISECONDS.sleep(l_dirichletdistributionsources1_G_backoff);
424 l_dirichletdistributionsources1_G_backoff = Math.max(1024, l_dirichletdistributionsources1_G_backoff * 2);
425 if (control.isFailing) throw new FailureAssistException();
426 if (Thread.interrupted()) throw new InterruptedException();
427 }
428 }
429 synchronized(this.getClass()) {
430 f_dirichletdistributionsources1_G = null;
431 }
432 synchronized(this.getClass()) {
433 f_enumerateddistributionsamplersperformance0_G = null;
434 }
435 }
436 res.allOps += res.measuredOps * batchSize;
437 res.allOps *= opsPerInv;
438 res.allOps /= batchSize;
439 res.measuredOps *= opsPerInv;
440 BenchmarkTaskResult results = new BenchmarkTaskResult((long)res.allOps, (long)res.measuredOps);
441 results.add(new SampleTimeResult(ResultRole.PRIMARY, "singleSampleDirichlet", buffer, benchmarkParams.getTimeUnit()));
442 this.blackhole.evaporate("Yes, I am Stephen Hawking, and know a thing or two about black holes.");
443 return results;
444 } else
445 throw new IllegalStateException("Harness failed to distribute threads among groups properly");
446 }
447
448 public static void singleSampleDirichlet_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, EnumeratedDistributionSamplersPerformance_DirichletDistributionSources_jmhType l_dirichletdistributionsources1_G, EnumeratedDistributionSamplersPerformance_jmhType l_enumerateddistributionsamplersperformance0_G) throws Throwable {
449 long realTime = 0;
450 long operations = 0;
451 int rnd = (int)System.nanoTime();
452 int rndMask = startRndMask;
453 long time = 0;
454 int currentStride = 0;
455 do {
456 rnd = (rnd * 1664525 + 1013904223);
457 boolean sample = (rnd & rndMask) == 0;
458 if (sample) {
459 time = System.nanoTime();
460 }
461 for (int b = 0; b < batchSize; b++) {
462 if (control.volatileSpoiler) return;
463 blackhole.consume(l_enumerateddistributionsamplersperformance0_G.singleSampleDirichlet(l_dirichletdistributionsources1_G));
464 }
465 if (sample) {
466 buffer.add((System.nanoTime() - time) / opsPerInv);
467 if (currentStride++ > targetSamples) {
468 buffer.half();
469 currentStride = 0;
470 rndMask = (rndMask << 1) + 1;
471 }
472 }
473 operations++;
474 } while(!control.isDone);
475 startRndMask = Math.max(startRndMask, rndMask);
476 result.realTime = realTime;
477 result.measuredOps = operations;
478 }
479
480
481 public BenchmarkTaskResult singleSampleDirichlet_SingleShotTime(InfraControl control, ThreadParams threadParams) throws Throwable {
482 this.benchmarkParams = control.benchmarkParams;
483 this.iterationParams = control.iterationParams;
484 this.threadParams = threadParams;
485 this.notifyControl = control.notifyControl;
486 if (this.blackhole == null) {
487 this.blackhole = new Blackhole("Today's password is swordfish. I understand instantiating Blackholes directly is dangerous.");
488 }
489 if (threadParams.getSubgroupIndex() == 0) {
490 EnumeratedDistributionSamplersPerformance_jmhType l_enumerateddistributionsamplersperformance0_G = _jmh_tryInit_f_enumerateddistributionsamplersperformance0_G(control);
491 EnumeratedDistributionSamplersPerformance_DirichletDistributionSources_jmhType l_dirichletdistributionsources1_G = _jmh_tryInit_f_dirichletdistributionsources1_G(control);
492
493 control.preSetup();
494 if (EnumeratedDistributionSamplersPerformance_DirichletDistributionSources_jmhType.setupIterationMutexUpdater.compareAndSet(l_dirichletdistributionsources1_G, 0, 1)) {
495 try {
496 if (control.isFailing) throw new FailureAssistException();
497 if (!l_dirichletdistributionsources1_G.readyIteration) {
498 l_dirichletdistributionsources1_G.setup();
499 l_dirichletdistributionsources1_G.readyIteration = true;
500 }
501 } catch (Throwable t) {
502 control.isFailing = true;
503 throw t;
504 } finally {
505 EnumeratedDistributionSamplersPerformance_DirichletDistributionSources_jmhType.setupIterationMutexUpdater.set(l_dirichletdistributionsources1_G, 0);
506 }
507 } else {
508 while (EnumeratedDistributionSamplersPerformance_DirichletDistributionSources_jmhType.setupIterationMutexUpdater.get(l_dirichletdistributionsources1_G) == 1) {
509 if (control.isFailing) throw new FailureAssistException();
510 if (Thread.interrupted()) throw new InterruptedException();
511 }
512 }
513
514
515 notifyControl.startMeasurement = true;
516 RawResults res = new RawResults();
517 int batchSize = iterationParams.getBatchSize();
518 singleSampleDirichlet_ss_jmhStub(control, res, benchmarkParams, iterationParams, threadParams, blackhole, notifyControl, startRndMask, batchSize, l_dirichletdistributionsources1_G, l_enumerateddistributionsamplersperformance0_G);
519 control.preTearDown();
520 if (EnumeratedDistributionSamplersPerformance_DirichletDistributionSources_jmhType.tearIterationMutexUpdater.compareAndSet(l_dirichletdistributionsources1_G, 0, 1)) {
521 try {
522 if (control.isFailing) throw new FailureAssistException();
523 if (l_dirichletdistributionsources1_G.readyIteration) {
524 l_dirichletdistributionsources1_G.readyIteration = false;
525 }
526 } catch (Throwable t) {
527 control.isFailing = true;
528 throw t;
529 } finally {
530 EnumeratedDistributionSamplersPerformance_DirichletDistributionSources_jmhType.tearIterationMutexUpdater.set(l_dirichletdistributionsources1_G, 0);
531 }
532 } else {
533 while (EnumeratedDistributionSamplersPerformance_DirichletDistributionSources_jmhType.tearIterationMutexUpdater.get(l_dirichletdistributionsources1_G) == 1) {
534 if (control.isFailing) throw new FailureAssistException();
535 if (Thread.interrupted()) throw new InterruptedException();
536 }
537 }
538
539 if (control.isLastIteration()) {
540 if (EnumeratedDistributionSamplersPerformance_DirichletDistributionSources_jmhType.tearTrialMutexUpdater.compareAndSet(l_dirichletdistributionsources1_G, 0, 1)) {
541 try {
542 if (control.isFailing) throw new FailureAssistException();
543 if (l_dirichletdistributionsources1_G.readyTrial) {
544 l_dirichletdistributionsources1_G.readyTrial = false;
545 }
546 } catch (Throwable t) {
547 control.isFailing = true;
548 throw t;
549 } finally {
550 EnumeratedDistributionSamplersPerformance_DirichletDistributionSources_jmhType.tearTrialMutexUpdater.set(l_dirichletdistributionsources1_G, 0);
551 }
552 } else {
553 long l_dirichletdistributionsources1_G_backoff = 1;
554 while (EnumeratedDistributionSamplersPerformance_DirichletDistributionSources_jmhType.tearTrialMutexUpdater.get(l_dirichletdistributionsources1_G) == 1) {
555 TimeUnit.MILLISECONDS.sleep(l_dirichletdistributionsources1_G_backoff);
556 l_dirichletdistributionsources1_G_backoff = Math.max(1024, l_dirichletdistributionsources1_G_backoff * 2);
557 if (control.isFailing) throw new FailureAssistException();
558 if (Thread.interrupted()) throw new InterruptedException();
559 }
560 }
561 synchronized(this.getClass()) {
562 f_dirichletdistributionsources1_G = null;
563 }
564 synchronized(this.getClass()) {
565 f_enumerateddistributionsamplersperformance0_G = null;
566 }
567 }
568 int opsPerInv = control.benchmarkParams.getOpsPerInvocation();
569 long totalOps = opsPerInv;
570 BenchmarkTaskResult results = new BenchmarkTaskResult(totalOps, totalOps);
571 results.add(new SingleShotResult(ResultRole.PRIMARY, "singleSampleDirichlet", res.getTime(), totalOps, benchmarkParams.getTimeUnit()));
572 this.blackhole.evaporate("Yes, I am Stephen Hawking, and know a thing or two about black holes.");
573 return results;
574 } else
575 throw new IllegalStateException("Harness failed to distribute threads among groups properly");
576 }
577
578 public static void singleSampleDirichlet_ss_jmhStub(InfraControl control, RawResults result, BenchmarkParams benchmarkParams, IterationParams iterationParams, ThreadParams threadParams, Blackhole blackhole, Control notifyControl, int startRndMask, int batchSize, EnumeratedDistributionSamplersPerformance_DirichletDistributionSources_jmhType l_dirichletdistributionsources1_G, EnumeratedDistributionSamplersPerformance_jmhType l_enumerateddistributionsamplersperformance0_G) throws Throwable {
579 long realTime = 0;
580 result.startTime = System.nanoTime();
581 for (int b = 0; b < batchSize; b++) {
582 if (control.volatileSpoiler) return;
583 blackhole.consume(l_enumerateddistributionsamplersperformance0_G.singleSampleDirichlet(l_dirichletdistributionsources1_G));
584 }
585 result.stopTime = System.nanoTime();
586 result.realTime = realTime;
587 }
588
589
590 static volatile EnumeratedDistributionSamplersPerformance_DirichletDistributionSources_jmhType f_dirichletdistributionsources1_G;
591
592 EnumeratedDistributionSamplersPerformance_DirichletDistributionSources_jmhType _jmh_tryInit_f_dirichletdistributionsources1_G(InfraControl control) throws Throwable {
593 EnumeratedDistributionSamplersPerformance_DirichletDistributionSources_jmhType val = f_dirichletdistributionsources1_G;
594 if (val != null) {
595 return val;
596 }
597 synchronized(this.getClass()) {
598 try {
599 if (control.isFailing) throw new FailureAssistException();
600 val = f_dirichletdistributionsources1_G;
601 if (val != null) {
602 return val;
603 }
604 val = new EnumeratedDistributionSamplersPerformance_DirichletDistributionSources_jmhType();
605 Field f;
606 f = org.apache.commons.rng.examples.jmh.sampling.distribution.EnumeratedDistributionSamplersPerformance.DirichletDistributionSources.class.getDeclaredField("alpha");
607 f.setAccessible(true);
608 f.set(val, Double.valueOf(control.getParam("alpha")));
609 f = org.apache.commons.rng.examples.jmh.sampling.distribution.EnumeratedDistributionSamplersPerformance.DirichletDistributionSources.class.getDeclaredField("k");
610 f.setAccessible(true);
611 f.set(val, Integer.valueOf(control.getParam("k")));
612 f = org.apache.commons.rng.examples.jmh.sampling.distribution.EnumeratedDistributionSamplersPerformance.LocalRandomSources.class.getDeclaredField("randomSourceName");
613 f.setAccessible(true);
614 f.set(val, control.getParam("randomSourceName"));
615 f = org.apache.commons.rng.examples.jmh.sampling.distribution.EnumeratedDistributionSamplersPerformance.SamplerSources.class.getDeclaredField("samplerType");
616 f.setAccessible(true);
617 f.set(val, control.getParam("samplerType"));
618 val.setup();
619 val.readyTrial = true;
620 f_dirichletdistributionsources1_G = val;
621 } catch (Throwable t) {
622 control.isFailing = true;
623 throw t;
624 }
625 }
626 return val;
627 }
628
629 static volatile EnumeratedDistributionSamplersPerformance_jmhType f_enumerateddistributionsamplersperformance0_G;
630
631 EnumeratedDistributionSamplersPerformance_jmhType _jmh_tryInit_f_enumerateddistributionsamplersperformance0_G(InfraControl control) throws Throwable {
632 EnumeratedDistributionSamplersPerformance_jmhType val = f_enumerateddistributionsamplersperformance0_G;
633 if (val != null) {
634 return val;
635 }
636 synchronized(this.getClass()) {
637 try {
638 if (control.isFailing) throw new FailureAssistException();
639 val = f_enumerateddistributionsamplersperformance0_G;
640 if (val != null) {
641 return val;
642 }
643 val = new EnumeratedDistributionSamplersPerformance_jmhType();
644 val.readyTrial = true;
645 f_enumerateddistributionsamplersperformance0_G = val;
646 } catch (Throwable t) {
647 control.isFailing = true;
648 throw t;
649 }
650 }
651 return val;
652 }
653
654
655 }
656