View Javadoc
1   package org.apache.commons.geometry.examples.jmh.euclidean.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.geometry.examples.jmh.euclidean.jmh_generated.RegionBSPTree2DPerformance_CircularBoundaryInput_jmhType;
36  import org.apache.commons.geometry.examples.jmh.euclidean.jmh_generated.RegionBSPTree2DPerformance_jmhType;
37  public final class RegionBSPTree2DPerformance_insertConvexWorstCase_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 insertConvexWorstCase_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              RegionBSPTree2DPerformance_jmhType l_regionbsptree2dperformance0_0 = _jmh_tryInit_f_regionbsptree2dperformance0_0(control);
73              RegionBSPTree2DPerformance_CircularBoundaryInput_jmhType l_circularboundaryinput1_1 = _jmh_tryInit_f_circularboundaryinput1_1(control);
74  
75              control.preSetup();
76              l_circularboundaryinput1_1.setup();
77  
78  
79              control.announceWarmupReady();
80              while (control.warmupShouldWait) {
81                  blackhole.consume(l_regionbsptree2dperformance0_0.insertConvexWorstCase(l_circularboundaryinput1_1));
82                  res.allOps++;
83              }
84  
85              notifyControl.startMeasurement = true;
86              insertConvexWorstCase_thrpt_jmhStub(control, res, benchmarkParams, iterationParams, threadParams, blackhole, notifyControl, startRndMask, l_circularboundaryinput1_1, l_regionbsptree2dperformance0_0);
87              notifyControl.stopMeasurement = true;
88              control.announceWarmdownReady();
89              try {
90                  while (control.warmdownShouldWait) {
91                      blackhole.consume(l_regionbsptree2dperformance0_0.insertConvexWorstCase(l_circularboundaryinput1_1));
92                      res.allOps++;
93                  }
94                  control.preTearDown();
95              } catch (InterruptedException ie) {
96                  control.preTearDownForce();
97              }
98  
99              if (control.isLastIteration()) {
100                 f_circularboundaryinput1_1 = null;
101                 f_regionbsptree2dperformance0_0 = null;
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, "insertConvexWorstCase", 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 insertConvexWorstCase_thrpt_jmhStub(InfraControl control, RawResults result, BenchmarkParams benchmarkParams, IterationParams iterationParams, ThreadParams threadParams, Blackhole blackhole, Control notifyControl, int startRndMask, RegionBSPTree2DPerformance_CircularBoundaryInput_jmhType l_circularboundaryinput1_1, RegionBSPTree2DPerformance_jmhType l_regionbsptree2dperformance0_0) throws Throwable {
119         long operations = 0;
120         long realTime = 0;
121         result.startTime = System.nanoTime();
122         do {
123             blackhole.consume(l_regionbsptree2dperformance0_0.insertConvexWorstCase(l_circularboundaryinput1_1));
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 insertConvexWorstCase_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             RegionBSPTree2DPerformance_jmhType l_regionbsptree2dperformance0_0 = _jmh_tryInit_f_regionbsptree2dperformance0_0(control);
143             RegionBSPTree2DPerformance_CircularBoundaryInput_jmhType l_circularboundaryinput1_1 = _jmh_tryInit_f_circularboundaryinput1_1(control);
144 
145             control.preSetup();
146             l_circularboundaryinput1_1.setup();
147 
148 
149             control.announceWarmupReady();
150             while (control.warmupShouldWait) {
151                 blackhole.consume(l_regionbsptree2dperformance0_0.insertConvexWorstCase(l_circularboundaryinput1_1));
152                 res.allOps++;
153             }
154 
155             notifyControl.startMeasurement = true;
156             insertConvexWorstCase_avgt_jmhStub(control, res, benchmarkParams, iterationParams, threadParams, blackhole, notifyControl, startRndMask, l_circularboundaryinput1_1, l_regionbsptree2dperformance0_0);
157             notifyControl.stopMeasurement = true;
158             control.announceWarmdownReady();
159             try {
160                 while (control.warmdownShouldWait) {
161                     blackhole.consume(l_regionbsptree2dperformance0_0.insertConvexWorstCase(l_circularboundaryinput1_1));
162                     res.allOps++;
163                 }
164                 control.preTearDown();
165             } catch (InterruptedException ie) {
166                 control.preTearDownForce();
167             }
168 
169             if (control.isLastIteration()) {
170                 f_circularboundaryinput1_1 = null;
171                 f_regionbsptree2dperformance0_0 = null;
172             }
173             res.allOps += res.measuredOps;
174             int batchSize = iterationParams.getBatchSize();
175             int opsPerInv = benchmarkParams.getOpsPerInvocation();
176             res.allOps *= opsPerInv;
177             res.allOps /= batchSize;
178             res.measuredOps *= opsPerInv;
179             res.measuredOps /= batchSize;
180             BenchmarkTaskResult results = new BenchmarkTaskResult((long)res.allOps, (long)res.measuredOps);
181             results.add(new AverageTimeResult(ResultRole.PRIMARY, "insertConvexWorstCase", res.measuredOps, res.getTime(), benchmarkParams.getTimeUnit()));
182             this.blackhole.evaporate("Yes, I am Stephen Hawking, and know a thing or two about black holes.");
183             return results;
184         } else
185             throw new IllegalStateException("Harness failed to distribute threads among groups properly");
186     }
187 
188     public static void insertConvexWorstCase_avgt_jmhStub(InfraControl control, RawResults result, BenchmarkParams benchmarkParams, IterationParams iterationParams, ThreadParams threadParams, Blackhole blackhole, Control notifyControl, int startRndMask, RegionBSPTree2DPerformance_CircularBoundaryInput_jmhType l_circularboundaryinput1_1, RegionBSPTree2DPerformance_jmhType l_regionbsptree2dperformance0_0) throws Throwable {
189         long operations = 0;
190         long realTime = 0;
191         result.startTime = System.nanoTime();
192         do {
193             blackhole.consume(l_regionbsptree2dperformance0_0.insertConvexWorstCase(l_circularboundaryinput1_1));
194             operations++;
195         } while(!control.isDone);
196         result.stopTime = System.nanoTime();
197         result.realTime = realTime;
198         result.measuredOps = operations;
199     }
200 
201 
202     public BenchmarkTaskResult insertConvexWorstCase_SampleTime(InfraControl control, ThreadParams threadParams) throws Throwable {
203         this.benchmarkParams = control.benchmarkParams;
204         this.iterationParams = control.iterationParams;
205         this.threadParams    = threadParams;
206         this.notifyControl   = control.notifyControl;
207         if (this.blackhole == null) {
208             this.blackhole = new Blackhole("Today's password is swordfish. I understand instantiating Blackholes directly is dangerous.");
209         }
210         if (threadParams.getSubgroupIndex() == 0) {
211             RawResults res = new RawResults();
212             RegionBSPTree2DPerformance_jmhType l_regionbsptree2dperformance0_0 = _jmh_tryInit_f_regionbsptree2dperformance0_0(control);
213             RegionBSPTree2DPerformance_CircularBoundaryInput_jmhType l_circularboundaryinput1_1 = _jmh_tryInit_f_circularboundaryinput1_1(control);
214 
215             control.preSetup();
216             l_circularboundaryinput1_1.setup();
217 
218 
219             control.announceWarmupReady();
220             while (control.warmupShouldWait) {
221                 blackhole.consume(l_regionbsptree2dperformance0_0.insertConvexWorstCase(l_circularboundaryinput1_1));
222                 res.allOps++;
223             }
224 
225             notifyControl.startMeasurement = true;
226             int targetSamples = (int) (control.getDuration(TimeUnit.MILLISECONDS) * 20); // at max, 20 timestamps per millisecond
227             int batchSize = iterationParams.getBatchSize();
228             int opsPerInv = benchmarkParams.getOpsPerInvocation();
229             SampleBuffer buffer = new SampleBuffer();
230             insertConvexWorstCase_sample_jmhStub(control, res, benchmarkParams, iterationParams, threadParams, blackhole, notifyControl, startRndMask, buffer, targetSamples, opsPerInv, batchSize, l_circularboundaryinput1_1, l_regionbsptree2dperformance0_0);
231             notifyControl.stopMeasurement = true;
232             control.announceWarmdownReady();
233             try {
234                 while (control.warmdownShouldWait) {
235                     blackhole.consume(l_regionbsptree2dperformance0_0.insertConvexWorstCase(l_circularboundaryinput1_1));
236                     res.allOps++;
237                 }
238                 control.preTearDown();
239             } catch (InterruptedException ie) {
240                 control.preTearDownForce();
241             }
242 
243             if (control.isLastIteration()) {
244                 f_circularboundaryinput1_1 = null;
245                 f_regionbsptree2dperformance0_0 = null;
246             }
247             res.allOps += res.measuredOps * batchSize;
248             res.allOps *= opsPerInv;
249             res.allOps /= batchSize;
250             res.measuredOps *= opsPerInv;
251             BenchmarkTaskResult results = new BenchmarkTaskResult((long)res.allOps, (long)res.measuredOps);
252             results.add(new SampleTimeResult(ResultRole.PRIMARY, "insertConvexWorstCase", buffer, benchmarkParams.getTimeUnit()));
253             this.blackhole.evaporate("Yes, I am Stephen Hawking, and know a thing or two about black holes.");
254             return results;
255         } else
256             throw new IllegalStateException("Harness failed to distribute threads among groups properly");
257     }
258 
259     public static void insertConvexWorstCase_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, RegionBSPTree2DPerformance_CircularBoundaryInput_jmhType l_circularboundaryinput1_1, RegionBSPTree2DPerformance_jmhType l_regionbsptree2dperformance0_0) throws Throwable {
260         long realTime = 0;
261         long operations = 0;
262         int rnd = (int)System.nanoTime();
263         int rndMask = startRndMask;
264         long time = 0;
265         int currentStride = 0;
266         do {
267             rnd = (rnd * 1664525 + 1013904223);
268             boolean sample = (rnd & rndMask) == 0;
269             if (sample) {
270                 time = System.nanoTime();
271             }
272             for (int b = 0; b < batchSize; b++) {
273                 if (control.volatileSpoiler) return;
274                 blackhole.consume(l_regionbsptree2dperformance0_0.insertConvexWorstCase(l_circularboundaryinput1_1));
275             }
276             if (sample) {
277                 buffer.add((System.nanoTime() - time) / opsPerInv);
278                 if (currentStride++ > targetSamples) {
279                     buffer.half();
280                     currentStride = 0;
281                     rndMask = (rndMask << 1) + 1;
282                 }
283             }
284             operations++;
285         } while(!control.isDone);
286         startRndMask = Math.max(startRndMask, rndMask);
287         result.realTime = realTime;
288         result.measuredOps = operations;
289     }
290 
291 
292     public BenchmarkTaskResult insertConvexWorstCase_SingleShotTime(InfraControl control, ThreadParams threadParams) throws Throwable {
293         this.benchmarkParams = control.benchmarkParams;
294         this.iterationParams = control.iterationParams;
295         this.threadParams    = threadParams;
296         this.notifyControl   = control.notifyControl;
297         if (this.blackhole == null) {
298             this.blackhole = new Blackhole("Today's password is swordfish. I understand instantiating Blackholes directly is dangerous.");
299         }
300         if (threadParams.getSubgroupIndex() == 0) {
301             RegionBSPTree2DPerformance_jmhType l_regionbsptree2dperformance0_0 = _jmh_tryInit_f_regionbsptree2dperformance0_0(control);
302             RegionBSPTree2DPerformance_CircularBoundaryInput_jmhType l_circularboundaryinput1_1 = _jmh_tryInit_f_circularboundaryinput1_1(control);
303 
304             control.preSetup();
305             l_circularboundaryinput1_1.setup();
306 
307 
308             notifyControl.startMeasurement = true;
309             RawResults res = new RawResults();
310             int batchSize = iterationParams.getBatchSize();
311             insertConvexWorstCase_ss_jmhStub(control, res, benchmarkParams, iterationParams, threadParams, blackhole, notifyControl, startRndMask, batchSize, l_circularboundaryinput1_1, l_regionbsptree2dperformance0_0);
312             control.preTearDown();
313 
314             if (control.isLastIteration()) {
315                 f_circularboundaryinput1_1 = null;
316                 f_regionbsptree2dperformance0_0 = null;
317             }
318             int opsPerInv = control.benchmarkParams.getOpsPerInvocation();
319             long totalOps = opsPerInv;
320             BenchmarkTaskResult results = new BenchmarkTaskResult(totalOps, totalOps);
321             results.add(new SingleShotResult(ResultRole.PRIMARY, "insertConvexWorstCase", res.getTime(), benchmarkParams.getTimeUnit()));
322             this.blackhole.evaporate("Yes, I am Stephen Hawking, and know a thing or two about black holes.");
323             return results;
324         } else
325             throw new IllegalStateException("Harness failed to distribute threads among groups properly");
326     }
327 
328     public static void insertConvexWorstCase_ss_jmhStub(InfraControl control, RawResults result, BenchmarkParams benchmarkParams, IterationParams iterationParams, ThreadParams threadParams, Blackhole blackhole, Control notifyControl, int startRndMask, int batchSize, RegionBSPTree2DPerformance_CircularBoundaryInput_jmhType l_circularboundaryinput1_1, RegionBSPTree2DPerformance_jmhType l_regionbsptree2dperformance0_0) throws Throwable {
329         long realTime = 0;
330         result.startTime = System.nanoTime();
331         for (int b = 0; b < batchSize; b++) {
332             if (control.volatileSpoiler) return;
333             blackhole.consume(l_regionbsptree2dperformance0_0.insertConvexWorstCase(l_circularboundaryinput1_1));
334         }
335         result.stopTime = System.nanoTime();
336         result.realTime = realTime;
337     }
338 
339     
340     RegionBSPTree2DPerformance_CircularBoundaryInput_jmhType f_circularboundaryinput1_1;
341     
342     RegionBSPTree2DPerformance_CircularBoundaryInput_jmhType _jmh_tryInit_f_circularboundaryinput1_1(InfraControl control) throws Throwable {
343         if (control.isFailing) throw new FailureAssistException();
344         RegionBSPTree2DPerformance_CircularBoundaryInput_jmhType val = f_circularboundaryinput1_1;
345         if (val == null) {
346             val = new RegionBSPTree2DPerformance_CircularBoundaryInput_jmhType();
347                 Field f;
348                 f = org.apache.commons.geometry.examples.jmh.euclidean.RegionBSPTree2DPerformance.CircularBoundaryInputBase.class.getDeclaredField("segments");
349                 f.setAccessible(true);
350                 f.set(val, Integer.valueOf(control.getParam("segments")));
351             f_circularboundaryinput1_1 = val;
352         }
353         return val;
354     }
355     
356     RegionBSPTree2DPerformance_jmhType f_regionbsptree2dperformance0_0;
357     
358     RegionBSPTree2DPerformance_jmhType _jmh_tryInit_f_regionbsptree2dperformance0_0(InfraControl control) throws Throwable {
359         if (control.isFailing) throw new FailureAssistException();
360         RegionBSPTree2DPerformance_jmhType val = f_regionbsptree2dperformance0_0;
361         if (val == null) {
362             val = new RegionBSPTree2DPerformance_jmhType();
363             f_regionbsptree2dperformance0_0 = val;
364         }
365         return val;
366     }
367 
368 
369 }
370