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