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