1 package org.apache.commons.statistics.examples.jmh.descriptive.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.statistics.examples.jmh.descriptive.jmh_generated.IntMomentPerformance_jmhType;
36 import org.apache.commons.statistics.examples.jmh.descriptive.jmh_generated.IntMomentPerformance_IntVarianceDataSource_jmhType;
37 import org.apache.commons.statistics.examples.jmh.descriptive.jmh_generated.IntMomentPerformance_IntVarianceFunctionSource_jmhType;
38 public final class IntMomentPerformance_intVariance_jmhTest {
39
40 byte p000, p001, p002, p003, p004, p005, p006, p007, p008, p009, p010, p011, p012, p013, p014, p015;
41 byte p016, p017, p018, p019, p020, p021, p022, p023, p024, p025, p026, p027, p028, p029, p030, p031;
42 byte p032, p033, p034, p035, p036, p037, p038, p039, p040, p041, p042, p043, p044, p045, p046, p047;
43 byte p048, p049, p050, p051, p052, p053, p054, p055, p056, p057, p058, p059, p060, p061, p062, p063;
44 byte p064, p065, p066, p067, p068, p069, p070, p071, p072, p073, p074, p075, p076, p077, p078, p079;
45 byte p080, p081, p082, p083, p084, p085, p086, p087, p088, p089, p090, p091, p092, p093, p094, p095;
46 byte p096, p097, p098, p099, p100, p101, p102, p103, p104, p105, p106, p107, p108, p109, p110, p111;
47 byte p112, p113, p114, p115, p116, p117, p118, p119, p120, p121, p122, p123, p124, p125, p126, p127;
48 byte p128, p129, p130, p131, p132, p133, p134, p135, p136, p137, p138, p139, p140, p141, p142, p143;
49 byte p144, p145, p146, p147, p148, p149, p150, p151, p152, p153, p154, p155, p156, p157, p158, p159;
50 byte p160, p161, p162, p163, p164, p165, p166, p167, p168, p169, p170, p171, p172, p173, p174, p175;
51 byte p176, p177, p178, p179, p180, p181, p182, p183, p184, p185, p186, p187, p188, p189, p190, p191;
52 byte p192, p193, p194, p195, p196, p197, p198, p199, p200, p201, p202, p203, p204, p205, p206, p207;
53 byte p208, p209, p210, p211, p212, p213, p214, p215, p216, p217, p218, p219, p220, p221, p222, p223;
54 byte p224, p225, p226, p227, p228, p229, p230, p231, p232, p233, p234, p235, p236, p237, p238, p239;
55 byte p240, p241, p242, p243, p244, p245, p246, p247, p248, p249, p250, p251, p252, p253, p254, p255;
56 int startRndMask;
57 BenchmarkParams benchmarkParams;
58 IterationParams iterationParams;
59 ThreadParams threadParams;
60 Blackhole blackhole;
61 Control notifyControl;
62
63 public BenchmarkTaskResult intVariance_Throughput(InfraControl control, ThreadParams threadParams) throws Throwable {
64 this.benchmarkParams = control.benchmarkParams;
65 this.iterationParams = control.iterationParams;
66 this.threadParams = threadParams;
67 this.notifyControl = control.notifyControl;
68 if (this.blackhole == null) {
69 this.blackhole = new Blackhole("Today's password is swordfish. I understand instantiating Blackholes directly is dangerous.");
70 }
71 if (threadParams.getSubgroupIndex() == 0) {
72 RawResults res = new RawResults();
73 IntMomentPerformance_jmhType l_intmomentperformance0_G = _jmh_tryInit_f_intmomentperformance0_G(control);
74 IntMomentPerformance_IntVarianceDataSource_jmhType l_intvariancedatasource2_G = _jmh_tryInit_f_intvariancedatasource2_G(control);
75 IntMomentPerformance_IntVarianceFunctionSource_jmhType l_intvariancefunctionsource1_G = _jmh_tryInit_f_intvariancefunctionsource1_G(control);
76
77 control.preSetup();
78 if (IntMomentPerformance_IntVarianceFunctionSource_jmhType.setupIterationMutexUpdater.compareAndSet(l_intvariancefunctionsource1_G, 0, 1)) {
79 try {
80 if (control.isFailing) throw new FailureAssistException();
81 if (!l_intvariancefunctionsource1_G.readyIteration) {
82 l_intvariancefunctionsource1_G.setup();
83 l_intvariancefunctionsource1_G.readyIteration = true;
84 }
85 } catch (Throwable t) {
86 control.isFailing = true;
87 throw t;
88 } finally {
89 IntMomentPerformance_IntVarianceFunctionSource_jmhType.setupIterationMutexUpdater.set(l_intvariancefunctionsource1_G, 0);
90 }
91 } else {
92 while (IntMomentPerformance_IntVarianceFunctionSource_jmhType.setupIterationMutexUpdater.get(l_intvariancefunctionsource1_G) == 1) {
93 if (control.isFailing) throw new FailureAssistException();
94 if (Thread.interrupted()) throw new InterruptedException();
95 }
96 }
97
98
99 control.announceWarmupReady();
100 while (control.warmupShouldWait) {
101 l_intmomentperformance0_G.intVariance(l_intvariancefunctionsource1_G, l_intvariancedatasource2_G, blackhole);
102 if (control.shouldYield) Thread.yield();
103 res.allOps++;
104 }
105
106 notifyControl.startMeasurement = true;
107 intVariance_thrpt_jmhStub(control, res, benchmarkParams, iterationParams, threadParams, blackhole, notifyControl, startRndMask, l_intvariancefunctionsource1_G, l_intvariancedatasource2_G, l_intmomentperformance0_G);
108 notifyControl.stopMeasurement = true;
109 control.announceWarmdownReady();
110 try {
111 while (control.warmdownShouldWait) {
112 l_intmomentperformance0_G.intVariance(l_intvariancefunctionsource1_G, l_intvariancedatasource2_G, blackhole);
113 if (control.shouldYield) Thread.yield();
114 res.allOps++;
115 }
116 } catch (Throwable e) {
117 if (!(e instanceof InterruptedException)) throw e;
118 }
119 control.preTearDown();
120 if (IntMomentPerformance_IntVarianceFunctionSource_jmhType.tearIterationMutexUpdater.compareAndSet(l_intvariancefunctionsource1_G, 0, 1)) {
121 try {
122 if (control.isFailing) throw new FailureAssistException();
123 if (l_intvariancefunctionsource1_G.readyIteration) {
124 l_intvariancefunctionsource1_G.readyIteration = false;
125 }
126 } catch (Throwable t) {
127 control.isFailing = true;
128 throw t;
129 } finally {
130 IntMomentPerformance_IntVarianceFunctionSource_jmhType.tearIterationMutexUpdater.set(l_intvariancefunctionsource1_G, 0);
131 }
132 } else {
133 while (IntMomentPerformance_IntVarianceFunctionSource_jmhType.tearIterationMutexUpdater.get(l_intvariancefunctionsource1_G) == 1) {
134 if (control.isFailing) throw new FailureAssistException();
135 if (Thread.interrupted()) throw new InterruptedException();
136 }
137 }
138
139 if (control.isLastIteration()) {
140 if (IntMomentPerformance_IntVarianceDataSource_jmhType.tearTrialMutexUpdater.compareAndSet(l_intvariancedatasource2_G, 0, 1)) {
141 try {
142 if (control.isFailing) throw new FailureAssistException();
143 if (l_intvariancedatasource2_G.readyTrial) {
144 l_intvariancedatasource2_G.readyTrial = false;
145 }
146 } catch (Throwable t) {
147 control.isFailing = true;
148 throw t;
149 } finally {
150 IntMomentPerformance_IntVarianceDataSource_jmhType.tearTrialMutexUpdater.set(l_intvariancedatasource2_G, 0);
151 }
152 } else {
153 long l_intvariancedatasource2_G_backoff = 1;
154 while (IntMomentPerformance_IntVarianceDataSource_jmhType.tearTrialMutexUpdater.get(l_intvariancedatasource2_G) == 1) {
155 TimeUnit.MILLISECONDS.sleep(l_intvariancedatasource2_G_backoff);
156 l_intvariancedatasource2_G_backoff = Math.max(1024, l_intvariancedatasource2_G_backoff * 2);
157 if (control.isFailing) throw new FailureAssistException();
158 if (Thread.interrupted()) throw new InterruptedException();
159 }
160 }
161 synchronized(this.getClass()) {
162 f_intvariancefunctionsource1_G = null;
163 }
164 synchronized(this.getClass()) {
165 f_intvariancedatasource2_G = null;
166 }
167 synchronized(this.getClass()) {
168 f_intmomentperformance0_G = null;
169 }
170 }
171 res.allOps += res.measuredOps;
172 int batchSize = iterationParams.getBatchSize();
173 int opsPerInv = benchmarkParams.getOpsPerInvocation();
174 res.allOps *= opsPerInv;
175 res.allOps /= batchSize;
176 res.measuredOps *= opsPerInv;
177 res.measuredOps /= batchSize;
178 BenchmarkTaskResult results = new BenchmarkTaskResult((long)res.allOps, (long)res.measuredOps);
179 results.add(new ThroughputResult(ResultRole.PRIMARY, "intVariance", res.measuredOps, res.getTime(), benchmarkParams.getTimeUnit()));
180 this.blackhole.evaporate("Yes, I am Stephen Hawking, and know a thing or two about black holes.");
181 return results;
182 } else
183 throw new IllegalStateException("Harness failed to distribute threads among groups properly");
184 }
185
186 public static void intVariance_thrpt_jmhStub(InfraControl control, RawResults result, BenchmarkParams benchmarkParams, IterationParams iterationParams, ThreadParams threadParams, Blackhole blackhole, Control notifyControl, int startRndMask, IntMomentPerformance_IntVarianceFunctionSource_jmhType l_intvariancefunctionsource1_G, IntMomentPerformance_IntVarianceDataSource_jmhType l_intvariancedatasource2_G, IntMomentPerformance_jmhType l_intmomentperformance0_G) throws Throwable {
187 long operations = 0;
188 long realTime = 0;
189 result.startTime = System.nanoTime();
190 do {
191 l_intmomentperformance0_G.intVariance(l_intvariancefunctionsource1_G, l_intvariancedatasource2_G, blackhole);
192 operations++;
193 } while(!control.isDone);
194 result.stopTime = System.nanoTime();
195 result.realTime = realTime;
196 result.measuredOps = operations;
197 }
198
199
200 public BenchmarkTaskResult intVariance_AverageTime(InfraControl control, ThreadParams threadParams) throws Throwable {
201 this.benchmarkParams = control.benchmarkParams;
202 this.iterationParams = control.iterationParams;
203 this.threadParams = threadParams;
204 this.notifyControl = control.notifyControl;
205 if (this.blackhole == null) {
206 this.blackhole = new Blackhole("Today's password is swordfish. I understand instantiating Blackholes directly is dangerous.");
207 }
208 if (threadParams.getSubgroupIndex() == 0) {
209 RawResults res = new RawResults();
210 IntMomentPerformance_jmhType l_intmomentperformance0_G = _jmh_tryInit_f_intmomentperformance0_G(control);
211 IntMomentPerformance_IntVarianceDataSource_jmhType l_intvariancedatasource2_G = _jmh_tryInit_f_intvariancedatasource2_G(control);
212 IntMomentPerformance_IntVarianceFunctionSource_jmhType l_intvariancefunctionsource1_G = _jmh_tryInit_f_intvariancefunctionsource1_G(control);
213
214 control.preSetup();
215 if (IntMomentPerformance_IntVarianceFunctionSource_jmhType.setupIterationMutexUpdater.compareAndSet(l_intvariancefunctionsource1_G, 0, 1)) {
216 try {
217 if (control.isFailing) throw new FailureAssistException();
218 if (!l_intvariancefunctionsource1_G.readyIteration) {
219 l_intvariancefunctionsource1_G.setup();
220 l_intvariancefunctionsource1_G.readyIteration = true;
221 }
222 } catch (Throwable t) {
223 control.isFailing = true;
224 throw t;
225 } finally {
226 IntMomentPerformance_IntVarianceFunctionSource_jmhType.setupIterationMutexUpdater.set(l_intvariancefunctionsource1_G, 0);
227 }
228 } else {
229 while (IntMomentPerformance_IntVarianceFunctionSource_jmhType.setupIterationMutexUpdater.get(l_intvariancefunctionsource1_G) == 1) {
230 if (control.isFailing) throw new FailureAssistException();
231 if (Thread.interrupted()) throw new InterruptedException();
232 }
233 }
234
235
236 control.announceWarmupReady();
237 while (control.warmupShouldWait) {
238 l_intmomentperformance0_G.intVariance(l_intvariancefunctionsource1_G, l_intvariancedatasource2_G, blackhole);
239 if (control.shouldYield) Thread.yield();
240 res.allOps++;
241 }
242
243 notifyControl.startMeasurement = true;
244 intVariance_avgt_jmhStub(control, res, benchmarkParams, iterationParams, threadParams, blackhole, notifyControl, startRndMask, l_intvariancefunctionsource1_G, l_intvariancedatasource2_G, l_intmomentperformance0_G);
245 notifyControl.stopMeasurement = true;
246 control.announceWarmdownReady();
247 try {
248 while (control.warmdownShouldWait) {
249 l_intmomentperformance0_G.intVariance(l_intvariancefunctionsource1_G, l_intvariancedatasource2_G, blackhole);
250 if (control.shouldYield) Thread.yield();
251 res.allOps++;
252 }
253 } catch (Throwable e) {
254 if (!(e instanceof InterruptedException)) throw e;
255 }
256 control.preTearDown();
257 if (IntMomentPerformance_IntVarianceFunctionSource_jmhType.tearIterationMutexUpdater.compareAndSet(l_intvariancefunctionsource1_G, 0, 1)) {
258 try {
259 if (control.isFailing) throw new FailureAssistException();
260 if (l_intvariancefunctionsource1_G.readyIteration) {
261 l_intvariancefunctionsource1_G.readyIteration = false;
262 }
263 } catch (Throwable t) {
264 control.isFailing = true;
265 throw t;
266 } finally {
267 IntMomentPerformance_IntVarianceFunctionSource_jmhType.tearIterationMutexUpdater.set(l_intvariancefunctionsource1_G, 0);
268 }
269 } else {
270 while (IntMomentPerformance_IntVarianceFunctionSource_jmhType.tearIterationMutexUpdater.get(l_intvariancefunctionsource1_G) == 1) {
271 if (control.isFailing) throw new FailureAssistException();
272 if (Thread.interrupted()) throw new InterruptedException();
273 }
274 }
275
276 if (control.isLastIteration()) {
277 if (IntMomentPerformance_IntVarianceDataSource_jmhType.tearTrialMutexUpdater.compareAndSet(l_intvariancedatasource2_G, 0, 1)) {
278 try {
279 if (control.isFailing) throw new FailureAssistException();
280 if (l_intvariancedatasource2_G.readyTrial) {
281 l_intvariancedatasource2_G.readyTrial = false;
282 }
283 } catch (Throwable t) {
284 control.isFailing = true;
285 throw t;
286 } finally {
287 IntMomentPerformance_IntVarianceDataSource_jmhType.tearTrialMutexUpdater.set(l_intvariancedatasource2_G, 0);
288 }
289 } else {
290 long l_intvariancedatasource2_G_backoff = 1;
291 while (IntMomentPerformance_IntVarianceDataSource_jmhType.tearTrialMutexUpdater.get(l_intvariancedatasource2_G) == 1) {
292 TimeUnit.MILLISECONDS.sleep(l_intvariancedatasource2_G_backoff);
293 l_intvariancedatasource2_G_backoff = Math.max(1024, l_intvariancedatasource2_G_backoff * 2);
294 if (control.isFailing) throw new FailureAssistException();
295 if (Thread.interrupted()) throw new InterruptedException();
296 }
297 }
298 synchronized(this.getClass()) {
299 f_intvariancefunctionsource1_G = null;
300 }
301 synchronized(this.getClass()) {
302 f_intvariancedatasource2_G = null;
303 }
304 synchronized(this.getClass()) {
305 f_intmomentperformance0_G = null;
306 }
307 }
308 res.allOps += res.measuredOps;
309 int batchSize = iterationParams.getBatchSize();
310 int opsPerInv = benchmarkParams.getOpsPerInvocation();
311 res.allOps *= opsPerInv;
312 res.allOps /= batchSize;
313 res.measuredOps *= opsPerInv;
314 res.measuredOps /= batchSize;
315 BenchmarkTaskResult results = new BenchmarkTaskResult((long)res.allOps, (long)res.measuredOps);
316 results.add(new AverageTimeResult(ResultRole.PRIMARY, "intVariance", res.measuredOps, res.getTime(), benchmarkParams.getTimeUnit()));
317 this.blackhole.evaporate("Yes, I am Stephen Hawking, and know a thing or two about black holes.");
318 return results;
319 } else
320 throw new IllegalStateException("Harness failed to distribute threads among groups properly");
321 }
322
323 public static void intVariance_avgt_jmhStub(InfraControl control, RawResults result, BenchmarkParams benchmarkParams, IterationParams iterationParams, ThreadParams threadParams, Blackhole blackhole, Control notifyControl, int startRndMask, IntMomentPerformance_IntVarianceFunctionSource_jmhType l_intvariancefunctionsource1_G, IntMomentPerformance_IntVarianceDataSource_jmhType l_intvariancedatasource2_G, IntMomentPerformance_jmhType l_intmomentperformance0_G) throws Throwable {
324 long operations = 0;
325 long realTime = 0;
326 result.startTime = System.nanoTime();
327 do {
328 l_intmomentperformance0_G.intVariance(l_intvariancefunctionsource1_G, l_intvariancedatasource2_G, blackhole);
329 operations++;
330 } while(!control.isDone);
331 result.stopTime = System.nanoTime();
332 result.realTime = realTime;
333 result.measuredOps = operations;
334 }
335
336
337 public BenchmarkTaskResult intVariance_SampleTime(InfraControl control, ThreadParams threadParams) throws Throwable {
338 this.benchmarkParams = control.benchmarkParams;
339 this.iterationParams = control.iterationParams;
340 this.threadParams = threadParams;
341 this.notifyControl = control.notifyControl;
342 if (this.blackhole == null) {
343 this.blackhole = new Blackhole("Today's password is swordfish. I understand instantiating Blackholes directly is dangerous.");
344 }
345 if (threadParams.getSubgroupIndex() == 0) {
346 RawResults res = new RawResults();
347 IntMomentPerformance_jmhType l_intmomentperformance0_G = _jmh_tryInit_f_intmomentperformance0_G(control);
348 IntMomentPerformance_IntVarianceDataSource_jmhType l_intvariancedatasource2_G = _jmh_tryInit_f_intvariancedatasource2_G(control);
349 IntMomentPerformance_IntVarianceFunctionSource_jmhType l_intvariancefunctionsource1_G = _jmh_tryInit_f_intvariancefunctionsource1_G(control);
350
351 control.preSetup();
352 if (IntMomentPerformance_IntVarianceFunctionSource_jmhType.setupIterationMutexUpdater.compareAndSet(l_intvariancefunctionsource1_G, 0, 1)) {
353 try {
354 if (control.isFailing) throw new FailureAssistException();
355 if (!l_intvariancefunctionsource1_G.readyIteration) {
356 l_intvariancefunctionsource1_G.setup();
357 l_intvariancefunctionsource1_G.readyIteration = true;
358 }
359 } catch (Throwable t) {
360 control.isFailing = true;
361 throw t;
362 } finally {
363 IntMomentPerformance_IntVarianceFunctionSource_jmhType.setupIterationMutexUpdater.set(l_intvariancefunctionsource1_G, 0);
364 }
365 } else {
366 while (IntMomentPerformance_IntVarianceFunctionSource_jmhType.setupIterationMutexUpdater.get(l_intvariancefunctionsource1_G) == 1) {
367 if (control.isFailing) throw new FailureAssistException();
368 if (Thread.interrupted()) throw new InterruptedException();
369 }
370 }
371
372
373 control.announceWarmupReady();
374 while (control.warmupShouldWait) {
375 l_intmomentperformance0_G.intVariance(l_intvariancefunctionsource1_G, l_intvariancedatasource2_G, blackhole);
376 if (control.shouldYield) Thread.yield();
377 res.allOps++;
378 }
379
380 notifyControl.startMeasurement = true;
381 int targetSamples = (int) (control.getDuration(TimeUnit.MILLISECONDS) * 20);
382 int batchSize = iterationParams.getBatchSize();
383 int opsPerInv = benchmarkParams.getOpsPerInvocation();
384 SampleBuffer buffer = new SampleBuffer();
385 intVariance_sample_jmhStub(control, res, benchmarkParams, iterationParams, threadParams, blackhole, notifyControl, startRndMask, buffer, targetSamples, opsPerInv, batchSize, l_intvariancefunctionsource1_G, l_intvariancedatasource2_G, l_intmomentperformance0_G);
386 notifyControl.stopMeasurement = true;
387 control.announceWarmdownReady();
388 try {
389 while (control.warmdownShouldWait) {
390 l_intmomentperformance0_G.intVariance(l_intvariancefunctionsource1_G, l_intvariancedatasource2_G, blackhole);
391 if (control.shouldYield) Thread.yield();
392 res.allOps++;
393 }
394 } catch (Throwable e) {
395 if (!(e instanceof InterruptedException)) throw e;
396 }
397 control.preTearDown();
398 if (IntMomentPerformance_IntVarianceFunctionSource_jmhType.tearIterationMutexUpdater.compareAndSet(l_intvariancefunctionsource1_G, 0, 1)) {
399 try {
400 if (control.isFailing) throw new FailureAssistException();
401 if (l_intvariancefunctionsource1_G.readyIteration) {
402 l_intvariancefunctionsource1_G.readyIteration = false;
403 }
404 } catch (Throwable t) {
405 control.isFailing = true;
406 throw t;
407 } finally {
408 IntMomentPerformance_IntVarianceFunctionSource_jmhType.tearIterationMutexUpdater.set(l_intvariancefunctionsource1_G, 0);
409 }
410 } else {
411 while (IntMomentPerformance_IntVarianceFunctionSource_jmhType.tearIterationMutexUpdater.get(l_intvariancefunctionsource1_G) == 1) {
412 if (control.isFailing) throw new FailureAssistException();
413 if (Thread.interrupted()) throw new InterruptedException();
414 }
415 }
416
417 if (control.isLastIteration()) {
418 if (IntMomentPerformance_IntVarianceDataSource_jmhType.tearTrialMutexUpdater.compareAndSet(l_intvariancedatasource2_G, 0, 1)) {
419 try {
420 if (control.isFailing) throw new FailureAssistException();
421 if (l_intvariancedatasource2_G.readyTrial) {
422 l_intvariancedatasource2_G.readyTrial = false;
423 }
424 } catch (Throwable t) {
425 control.isFailing = true;
426 throw t;
427 } finally {
428 IntMomentPerformance_IntVarianceDataSource_jmhType.tearTrialMutexUpdater.set(l_intvariancedatasource2_G, 0);
429 }
430 } else {
431 long l_intvariancedatasource2_G_backoff = 1;
432 while (IntMomentPerformance_IntVarianceDataSource_jmhType.tearTrialMutexUpdater.get(l_intvariancedatasource2_G) == 1) {
433 TimeUnit.MILLISECONDS.sleep(l_intvariancedatasource2_G_backoff);
434 l_intvariancedatasource2_G_backoff = Math.max(1024, l_intvariancedatasource2_G_backoff * 2);
435 if (control.isFailing) throw new FailureAssistException();
436 if (Thread.interrupted()) throw new InterruptedException();
437 }
438 }
439 synchronized(this.getClass()) {
440 f_intvariancefunctionsource1_G = null;
441 }
442 synchronized(this.getClass()) {
443 f_intvariancedatasource2_G = null;
444 }
445 synchronized(this.getClass()) {
446 f_intmomentperformance0_G = null;
447 }
448 }
449 res.allOps += res.measuredOps * batchSize;
450 res.allOps *= opsPerInv;
451 res.allOps /= batchSize;
452 res.measuredOps *= opsPerInv;
453 BenchmarkTaskResult results = new BenchmarkTaskResult((long)res.allOps, (long)res.measuredOps);
454 results.add(new SampleTimeResult(ResultRole.PRIMARY, "intVariance", buffer, benchmarkParams.getTimeUnit()));
455 this.blackhole.evaporate("Yes, I am Stephen Hawking, and know a thing or two about black holes.");
456 return results;
457 } else
458 throw new IllegalStateException("Harness failed to distribute threads among groups properly");
459 }
460
461 public static void intVariance_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, IntMomentPerformance_IntVarianceFunctionSource_jmhType l_intvariancefunctionsource1_G, IntMomentPerformance_IntVarianceDataSource_jmhType l_intvariancedatasource2_G, IntMomentPerformance_jmhType l_intmomentperformance0_G) throws Throwable {
462 long realTime = 0;
463 long operations = 0;
464 int rnd = (int)System.nanoTime();
465 int rndMask = startRndMask;
466 long time = 0;
467 int currentStride = 0;
468 do {
469 rnd = (rnd * 1664525 + 1013904223);
470 boolean sample = (rnd & rndMask) == 0;
471 if (sample) {
472 time = System.nanoTime();
473 }
474 for (int b = 0; b < batchSize; b++) {
475 if (control.volatileSpoiler) return;
476 l_intmomentperformance0_G.intVariance(l_intvariancefunctionsource1_G, l_intvariancedatasource2_G, blackhole);
477 }
478 if (sample) {
479 buffer.add((System.nanoTime() - time) / opsPerInv);
480 if (currentStride++ > targetSamples) {
481 buffer.half();
482 currentStride = 0;
483 rndMask = (rndMask << 1) + 1;
484 }
485 }
486 operations++;
487 } while(!control.isDone);
488 startRndMask = Math.max(startRndMask, rndMask);
489 result.realTime = realTime;
490 result.measuredOps = operations;
491 }
492
493
494 public BenchmarkTaskResult intVariance_SingleShotTime(InfraControl control, ThreadParams threadParams) throws Throwable {
495 this.benchmarkParams = control.benchmarkParams;
496 this.iterationParams = control.iterationParams;
497 this.threadParams = threadParams;
498 this.notifyControl = control.notifyControl;
499 if (this.blackhole == null) {
500 this.blackhole = new Blackhole("Today's password is swordfish. I understand instantiating Blackholes directly is dangerous.");
501 }
502 if (threadParams.getSubgroupIndex() == 0) {
503 IntMomentPerformance_jmhType l_intmomentperformance0_G = _jmh_tryInit_f_intmomentperformance0_G(control);
504 IntMomentPerformance_IntVarianceDataSource_jmhType l_intvariancedatasource2_G = _jmh_tryInit_f_intvariancedatasource2_G(control);
505 IntMomentPerformance_IntVarianceFunctionSource_jmhType l_intvariancefunctionsource1_G = _jmh_tryInit_f_intvariancefunctionsource1_G(control);
506
507 control.preSetup();
508 if (IntMomentPerformance_IntVarianceFunctionSource_jmhType.setupIterationMutexUpdater.compareAndSet(l_intvariancefunctionsource1_G, 0, 1)) {
509 try {
510 if (control.isFailing) throw new FailureAssistException();
511 if (!l_intvariancefunctionsource1_G.readyIteration) {
512 l_intvariancefunctionsource1_G.setup();
513 l_intvariancefunctionsource1_G.readyIteration = true;
514 }
515 } catch (Throwable t) {
516 control.isFailing = true;
517 throw t;
518 } finally {
519 IntMomentPerformance_IntVarianceFunctionSource_jmhType.setupIterationMutexUpdater.set(l_intvariancefunctionsource1_G, 0);
520 }
521 } else {
522 while (IntMomentPerformance_IntVarianceFunctionSource_jmhType.setupIterationMutexUpdater.get(l_intvariancefunctionsource1_G) == 1) {
523 if (control.isFailing) throw new FailureAssistException();
524 if (Thread.interrupted()) throw new InterruptedException();
525 }
526 }
527
528
529 notifyControl.startMeasurement = true;
530 RawResults res = new RawResults();
531 int batchSize = iterationParams.getBatchSize();
532 intVariance_ss_jmhStub(control, res, benchmarkParams, iterationParams, threadParams, blackhole, notifyControl, startRndMask, batchSize, l_intvariancefunctionsource1_G, l_intvariancedatasource2_G, l_intmomentperformance0_G);
533 control.preTearDown();
534 if (IntMomentPerformance_IntVarianceFunctionSource_jmhType.tearIterationMutexUpdater.compareAndSet(l_intvariancefunctionsource1_G, 0, 1)) {
535 try {
536 if (control.isFailing) throw new FailureAssistException();
537 if (l_intvariancefunctionsource1_G.readyIteration) {
538 l_intvariancefunctionsource1_G.readyIteration = false;
539 }
540 } catch (Throwable t) {
541 control.isFailing = true;
542 throw t;
543 } finally {
544 IntMomentPerformance_IntVarianceFunctionSource_jmhType.tearIterationMutexUpdater.set(l_intvariancefunctionsource1_G, 0);
545 }
546 } else {
547 while (IntMomentPerformance_IntVarianceFunctionSource_jmhType.tearIterationMutexUpdater.get(l_intvariancefunctionsource1_G) == 1) {
548 if (control.isFailing) throw new FailureAssistException();
549 if (Thread.interrupted()) throw new InterruptedException();
550 }
551 }
552
553 if (control.isLastIteration()) {
554 if (IntMomentPerformance_IntVarianceDataSource_jmhType.tearTrialMutexUpdater.compareAndSet(l_intvariancedatasource2_G, 0, 1)) {
555 try {
556 if (control.isFailing) throw new FailureAssistException();
557 if (l_intvariancedatasource2_G.readyTrial) {
558 l_intvariancedatasource2_G.readyTrial = false;
559 }
560 } catch (Throwable t) {
561 control.isFailing = true;
562 throw t;
563 } finally {
564 IntMomentPerformance_IntVarianceDataSource_jmhType.tearTrialMutexUpdater.set(l_intvariancedatasource2_G, 0);
565 }
566 } else {
567 long l_intvariancedatasource2_G_backoff = 1;
568 while (IntMomentPerformance_IntVarianceDataSource_jmhType.tearTrialMutexUpdater.get(l_intvariancedatasource2_G) == 1) {
569 TimeUnit.MILLISECONDS.sleep(l_intvariancedatasource2_G_backoff);
570 l_intvariancedatasource2_G_backoff = Math.max(1024, l_intvariancedatasource2_G_backoff * 2);
571 if (control.isFailing) throw new FailureAssistException();
572 if (Thread.interrupted()) throw new InterruptedException();
573 }
574 }
575 synchronized(this.getClass()) {
576 f_intvariancefunctionsource1_G = null;
577 }
578 synchronized(this.getClass()) {
579 f_intvariancedatasource2_G = null;
580 }
581 synchronized(this.getClass()) {
582 f_intmomentperformance0_G = null;
583 }
584 }
585 int opsPerInv = control.benchmarkParams.getOpsPerInvocation();
586 long totalOps = opsPerInv;
587 BenchmarkTaskResult results = new BenchmarkTaskResult(totalOps, totalOps);
588 results.add(new SingleShotResult(ResultRole.PRIMARY, "intVariance", res.getTime(), totalOps, benchmarkParams.getTimeUnit()));
589 this.blackhole.evaporate("Yes, I am Stephen Hawking, and know a thing or two about black holes.");
590 return results;
591 } else
592 throw new IllegalStateException("Harness failed to distribute threads among groups properly");
593 }
594
595 public static void intVariance_ss_jmhStub(InfraControl control, RawResults result, BenchmarkParams benchmarkParams, IterationParams iterationParams, ThreadParams threadParams, Blackhole blackhole, Control notifyControl, int startRndMask, int batchSize, IntMomentPerformance_IntVarianceFunctionSource_jmhType l_intvariancefunctionsource1_G, IntMomentPerformance_IntVarianceDataSource_jmhType l_intvariancedatasource2_G, IntMomentPerformance_jmhType l_intmomentperformance0_G) throws Throwable {
596 long realTime = 0;
597 result.startTime = System.nanoTime();
598 for (int b = 0; b < batchSize; b++) {
599 if (control.volatileSpoiler) return;
600 l_intmomentperformance0_G.intVariance(l_intvariancefunctionsource1_G, l_intvariancedatasource2_G, blackhole);
601 }
602 result.stopTime = System.nanoTime();
603 result.realTime = realTime;
604 }
605
606
607 static volatile IntMomentPerformance_jmhType f_intmomentperformance0_G;
608
609 IntMomentPerformance_jmhType _jmh_tryInit_f_intmomentperformance0_G(InfraControl control) throws Throwable {
610 IntMomentPerformance_jmhType val = f_intmomentperformance0_G;
611 if (val != null) {
612 return val;
613 }
614 synchronized(this.getClass()) {
615 try {
616 if (control.isFailing) throw new FailureAssistException();
617 val = f_intmomentperformance0_G;
618 if (val != null) {
619 return val;
620 }
621 val = new IntMomentPerformance_jmhType();
622 val.readyTrial = true;
623 f_intmomentperformance0_G = val;
624 } catch (Throwable t) {
625 control.isFailing = true;
626 throw t;
627 }
628 }
629 return val;
630 }
631
632 static volatile IntMomentPerformance_IntVarianceDataSource_jmhType f_intvariancedatasource2_G;
633
634 IntMomentPerformance_IntVarianceDataSource_jmhType _jmh_tryInit_f_intvariancedatasource2_G(InfraControl control) throws Throwable {
635 IntMomentPerformance_IntVarianceDataSource_jmhType val = f_intvariancedatasource2_G;
636 if (val != null) {
637 return val;
638 }
639 synchronized(this.getClass()) {
640 try {
641 if (control.isFailing) throw new FailureAssistException();
642 val = f_intvariancedatasource2_G;
643 if (val != null) {
644 return val;
645 }
646 val = new IntMomentPerformance_IntVarianceDataSource_jmhType();
647 Field f;
648 f = org.apache.commons.statistics.examples.jmh.descriptive.IntMomentPerformance.IntVarianceDataSource.class.getDeclaredField("bound");
649 f.setAccessible(true);
650 f.set(val, Integer.valueOf(control.getParam("bound")));
651 f = org.apache.commons.statistics.examples.jmh.descriptive.IntMomentPerformance.IntVarianceDataSource.class.getDeclaredField("combine");
652 f.setAccessible(true);
653 f.set(val, Integer.valueOf(control.getParam("combine")));
654 f = org.apache.commons.statistics.examples.jmh.descriptive.IntMomentPerformance.IntVarianceDataSource.class.getDeclaredField("maxSamples");
655 f.setAccessible(true);
656 f.set(val, Integer.valueOf(control.getParam("maxSamples")));
657 f = org.apache.commons.statistics.examples.jmh.descriptive.IntMomentPerformance.IntVarianceDataSource.class.getDeclaredField("minSamples");
658 f.setAccessible(true);
659 f.set(val, Integer.valueOf(control.getParam("minSamples")));
660 f = org.apache.commons.statistics.examples.jmh.descriptive.IntMomentPerformance.IntVarianceDataSource.class.getDeclaredField("origin");
661 f.setAccessible(true);
662 f.set(val, Integer.valueOf(control.getParam("origin")));
663 f = org.apache.commons.statistics.examples.jmh.descriptive.IntMomentPerformance.IntVarianceDataSource.class.getDeclaredField("poolSize");
664 f.setAccessible(true);
665 f.set(val, Integer.valueOf(control.getParam("poolSize")));
666 val.setup();
667 val.readyTrial = true;
668 f_intvariancedatasource2_G = val;
669 } catch (Throwable t) {
670 control.isFailing = true;
671 throw t;
672 }
673 }
674 return val;
675 }
676
677 static volatile IntMomentPerformance_IntVarianceFunctionSource_jmhType f_intvariancefunctionsource1_G;
678
679 IntMomentPerformance_IntVarianceFunctionSource_jmhType _jmh_tryInit_f_intvariancefunctionsource1_G(InfraControl control) throws Throwable {
680 IntMomentPerformance_IntVarianceFunctionSource_jmhType val = f_intvariancefunctionsource1_G;
681 if (val != null) {
682 return val;
683 }
684 synchronized(this.getClass()) {
685 try {
686 if (control.isFailing) throw new FailureAssistException();
687 val = f_intvariancefunctionsource1_G;
688 if (val != null) {
689 return val;
690 }
691 val = new IntMomentPerformance_IntVarianceFunctionSource_jmhType();
692 Field f;
693 f = org.apache.commons.statistics.examples.jmh.descriptive.IntMomentPerformance.IntVarianceFunctionSource.class.getDeclaredField("name");
694 f.setAccessible(true);
695 f.set(val, control.getParam("name"));
696 val.readyTrial = true;
697 f_intvariancefunctionsource1_G = val;
698 } catch (Throwable t) {
699 control.isFailing = true;
700 throw t;
701 }
702 }
703 return val;
704 }
705
706
707 }
708