View Javadoc
1   package io.netty5.handler.codec.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 io.netty5.handler.codec.jmh_generated.CodecOutputListBenchmark_jmhType;
36  public final class CodecOutputListBenchmark_codecOutList_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 codecOutList_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              CodecOutputListBenchmark_jmhType l_codecoutputlistbenchmark0_G = _jmh_tryInit_f_codecoutputlistbenchmark0_G(control);
72  
73              control.preSetup();
74  
75  
76              control.announceWarmupReady();
77              while (control.warmupShouldWait) {
78                  l_codecoutputlistbenchmark0_G.codecOutList();
79                  res.allOps++;
80              }
81  
82              notifyControl.startMeasurement = true;
83              codecOutList_thrpt_jmhStub(control, res, benchmarkParams, iterationParams, threadParams, blackhole, notifyControl, startRndMask, l_codecoutputlistbenchmark0_G);
84              notifyControl.stopMeasurement = true;
85              control.announceWarmdownReady();
86              try {
87                  while (control.warmdownShouldWait) {
88                      l_codecoutputlistbenchmark0_G.codecOutList();
89                      res.allOps++;
90                  }
91              } catch (Throwable e) {
92                  if (!(e instanceof InterruptedException)) throw e;
93              }
94              control.preTearDown();
95  
96              if (control.isLastIteration()) {
97                  if (CodecOutputListBenchmark_jmhType.tearTrialMutexUpdater.compareAndSet(l_codecoutputlistbenchmark0_G, 0, 1)) {
98                      try {
99                          if (control.isFailing) throw new FailureAssistException();
100                         if (l_codecoutputlistbenchmark0_G.readyTrial) {
101                             l_codecoutputlistbenchmark0_G.destroy();
102                             l_codecoutputlistbenchmark0_G.readyTrial = false;
103                         }
104                     } catch (Throwable t) {
105                         control.isFailing = true;
106                         throw t;
107                     } finally {
108                         CodecOutputListBenchmark_jmhType.tearTrialMutexUpdater.set(l_codecoutputlistbenchmark0_G, 0);
109                     }
110                 } else {
111                     long l_codecoutputlistbenchmark0_G_backoff = 1;
112                     while (CodecOutputListBenchmark_jmhType.tearTrialMutexUpdater.get(l_codecoutputlistbenchmark0_G) == 1) {
113                         TimeUnit.MILLISECONDS.sleep(l_codecoutputlistbenchmark0_G_backoff);
114                         l_codecoutputlistbenchmark0_G_backoff = Math.max(1024, l_codecoutputlistbenchmark0_G_backoff * 2);
115                         if (control.isFailing) throw new FailureAssistException();
116                         if (Thread.interrupted()) throw new InterruptedException();
117                     }
118                 }
119                 synchronized(this.getClass()) {
120                     f_codecoutputlistbenchmark0_G = null;
121                 }
122             }
123             res.allOps += res.measuredOps;
124             int batchSize = iterationParams.getBatchSize();
125             int opsPerInv = benchmarkParams.getOpsPerInvocation();
126             res.allOps *= opsPerInv;
127             res.allOps /= batchSize;
128             res.measuredOps *= opsPerInv;
129             res.measuredOps /= batchSize;
130             BenchmarkTaskResult results = new BenchmarkTaskResult((long)res.allOps, (long)res.measuredOps);
131             results.add(new ThroughputResult(ResultRole.PRIMARY, "codecOutList", res.measuredOps, res.getTime(), benchmarkParams.getTimeUnit()));
132             this.blackhole.evaporate("Yes, I am Stephen Hawking, and know a thing or two about black holes.");
133             return results;
134         } else
135             throw new IllegalStateException("Harness failed to distribute threads among groups properly");
136     }
137 
138     public static void codecOutList_thrpt_jmhStub(InfraControl control, RawResults result, BenchmarkParams benchmarkParams, IterationParams iterationParams, ThreadParams threadParams, Blackhole blackhole, Control notifyControl, int startRndMask, CodecOutputListBenchmark_jmhType l_codecoutputlistbenchmark0_G) throws Throwable {
139         long operations = 0;
140         long realTime = 0;
141         result.startTime = System.nanoTime();
142         do {
143             l_codecoutputlistbenchmark0_G.codecOutList();
144             operations++;
145         } while(!control.isDone);
146         result.stopTime = System.nanoTime();
147         result.realTime = realTime;
148         result.measuredOps = operations;
149     }
150 
151 
152     public BenchmarkTaskResult codecOutList_AverageTime(InfraControl control, ThreadParams threadParams) throws Throwable {
153         this.benchmarkParams = control.benchmarkParams;
154         this.iterationParams = control.iterationParams;
155         this.threadParams    = threadParams;
156         this.notifyControl   = control.notifyControl;
157         if (this.blackhole == null) {
158             this.blackhole = new Blackhole("Today's password is swordfish. I understand instantiating Blackholes directly is dangerous.");
159         }
160         if (threadParams.getSubgroupIndex() == 0) {
161             RawResults res = new RawResults();
162             CodecOutputListBenchmark_jmhType l_codecoutputlistbenchmark0_G = _jmh_tryInit_f_codecoutputlistbenchmark0_G(control);
163 
164             control.preSetup();
165 
166 
167             control.announceWarmupReady();
168             while (control.warmupShouldWait) {
169                 l_codecoutputlistbenchmark0_G.codecOutList();
170                 res.allOps++;
171             }
172 
173             notifyControl.startMeasurement = true;
174             codecOutList_avgt_jmhStub(control, res, benchmarkParams, iterationParams, threadParams, blackhole, notifyControl, startRndMask, l_codecoutputlistbenchmark0_G);
175             notifyControl.stopMeasurement = true;
176             control.announceWarmdownReady();
177             try {
178                 while (control.warmdownShouldWait) {
179                     l_codecoutputlistbenchmark0_G.codecOutList();
180                     res.allOps++;
181                 }
182             } catch (Throwable e) {
183                 if (!(e instanceof InterruptedException)) throw e;
184             }
185             control.preTearDown();
186 
187             if (control.isLastIteration()) {
188                 if (CodecOutputListBenchmark_jmhType.tearTrialMutexUpdater.compareAndSet(l_codecoutputlistbenchmark0_G, 0, 1)) {
189                     try {
190                         if (control.isFailing) throw new FailureAssistException();
191                         if (l_codecoutputlistbenchmark0_G.readyTrial) {
192                             l_codecoutputlistbenchmark0_G.destroy();
193                             l_codecoutputlistbenchmark0_G.readyTrial = false;
194                         }
195                     } catch (Throwable t) {
196                         control.isFailing = true;
197                         throw t;
198                     } finally {
199                         CodecOutputListBenchmark_jmhType.tearTrialMutexUpdater.set(l_codecoutputlistbenchmark0_G, 0);
200                     }
201                 } else {
202                     long l_codecoutputlistbenchmark0_G_backoff = 1;
203                     while (CodecOutputListBenchmark_jmhType.tearTrialMutexUpdater.get(l_codecoutputlistbenchmark0_G) == 1) {
204                         TimeUnit.MILLISECONDS.sleep(l_codecoutputlistbenchmark0_G_backoff);
205                         l_codecoutputlistbenchmark0_G_backoff = Math.max(1024, l_codecoutputlistbenchmark0_G_backoff * 2);
206                         if (control.isFailing) throw new FailureAssistException();
207                         if (Thread.interrupted()) throw new InterruptedException();
208                     }
209                 }
210                 synchronized(this.getClass()) {
211                     f_codecoutputlistbenchmark0_G = null;
212                 }
213             }
214             res.allOps += res.measuredOps;
215             int batchSize = iterationParams.getBatchSize();
216             int opsPerInv = benchmarkParams.getOpsPerInvocation();
217             res.allOps *= opsPerInv;
218             res.allOps /= batchSize;
219             res.measuredOps *= opsPerInv;
220             res.measuredOps /= batchSize;
221             BenchmarkTaskResult results = new BenchmarkTaskResult((long)res.allOps, (long)res.measuredOps);
222             results.add(new AverageTimeResult(ResultRole.PRIMARY, "codecOutList", res.measuredOps, res.getTime(), benchmarkParams.getTimeUnit()));
223             this.blackhole.evaporate("Yes, I am Stephen Hawking, and know a thing or two about black holes.");
224             return results;
225         } else
226             throw new IllegalStateException("Harness failed to distribute threads among groups properly");
227     }
228 
229     public static void codecOutList_avgt_jmhStub(InfraControl control, RawResults result, BenchmarkParams benchmarkParams, IterationParams iterationParams, ThreadParams threadParams, Blackhole blackhole, Control notifyControl, int startRndMask, CodecOutputListBenchmark_jmhType l_codecoutputlistbenchmark0_G) throws Throwable {
230         long operations = 0;
231         long realTime = 0;
232         result.startTime = System.nanoTime();
233         do {
234             l_codecoutputlistbenchmark0_G.codecOutList();
235             operations++;
236         } while(!control.isDone);
237         result.stopTime = System.nanoTime();
238         result.realTime = realTime;
239         result.measuredOps = operations;
240     }
241 
242 
243     public BenchmarkTaskResult codecOutList_SampleTime(InfraControl control, ThreadParams threadParams) throws Throwable {
244         this.benchmarkParams = control.benchmarkParams;
245         this.iterationParams = control.iterationParams;
246         this.threadParams    = threadParams;
247         this.notifyControl   = control.notifyControl;
248         if (this.blackhole == null) {
249             this.blackhole = new Blackhole("Today's password is swordfish. I understand instantiating Blackholes directly is dangerous.");
250         }
251         if (threadParams.getSubgroupIndex() == 0) {
252             RawResults res = new RawResults();
253             CodecOutputListBenchmark_jmhType l_codecoutputlistbenchmark0_G = _jmh_tryInit_f_codecoutputlistbenchmark0_G(control);
254 
255             control.preSetup();
256 
257 
258             control.announceWarmupReady();
259             while (control.warmupShouldWait) {
260                 l_codecoutputlistbenchmark0_G.codecOutList();
261                 res.allOps++;
262             }
263 
264             notifyControl.startMeasurement = true;
265             int targetSamples = (int) (control.getDuration(TimeUnit.MILLISECONDS) * 20); // at max, 20 timestamps per millisecond
266             int batchSize = iterationParams.getBatchSize();
267             int opsPerInv = benchmarkParams.getOpsPerInvocation();
268             SampleBuffer buffer = new SampleBuffer();
269             codecOutList_sample_jmhStub(control, res, benchmarkParams, iterationParams, threadParams, blackhole, notifyControl, startRndMask, buffer, targetSamples, opsPerInv, batchSize, l_codecoutputlistbenchmark0_G);
270             notifyControl.stopMeasurement = true;
271             control.announceWarmdownReady();
272             try {
273                 while (control.warmdownShouldWait) {
274                     l_codecoutputlistbenchmark0_G.codecOutList();
275                     res.allOps++;
276                 }
277             } catch (Throwable e) {
278                 if (!(e instanceof InterruptedException)) throw e;
279             }
280             control.preTearDown();
281 
282             if (control.isLastIteration()) {
283                 if (CodecOutputListBenchmark_jmhType.tearTrialMutexUpdater.compareAndSet(l_codecoutputlistbenchmark0_G, 0, 1)) {
284                     try {
285                         if (control.isFailing) throw new FailureAssistException();
286                         if (l_codecoutputlistbenchmark0_G.readyTrial) {
287                             l_codecoutputlistbenchmark0_G.destroy();
288                             l_codecoutputlistbenchmark0_G.readyTrial = false;
289                         }
290                     } catch (Throwable t) {
291                         control.isFailing = true;
292                         throw t;
293                     } finally {
294                         CodecOutputListBenchmark_jmhType.tearTrialMutexUpdater.set(l_codecoutputlistbenchmark0_G, 0);
295                     }
296                 } else {
297                     long l_codecoutputlistbenchmark0_G_backoff = 1;
298                     while (CodecOutputListBenchmark_jmhType.tearTrialMutexUpdater.get(l_codecoutputlistbenchmark0_G) == 1) {
299                         TimeUnit.MILLISECONDS.sleep(l_codecoutputlistbenchmark0_G_backoff);
300                         l_codecoutputlistbenchmark0_G_backoff = Math.max(1024, l_codecoutputlistbenchmark0_G_backoff * 2);
301                         if (control.isFailing) throw new FailureAssistException();
302                         if (Thread.interrupted()) throw new InterruptedException();
303                     }
304                 }
305                 synchronized(this.getClass()) {
306                     f_codecoutputlistbenchmark0_G = null;
307                 }
308             }
309             res.allOps += res.measuredOps * batchSize;
310             res.allOps *= opsPerInv;
311             res.allOps /= batchSize;
312             res.measuredOps *= opsPerInv;
313             BenchmarkTaskResult results = new BenchmarkTaskResult((long)res.allOps, (long)res.measuredOps);
314             results.add(new SampleTimeResult(ResultRole.PRIMARY, "codecOutList", buffer, benchmarkParams.getTimeUnit()));
315             this.blackhole.evaporate("Yes, I am Stephen Hawking, and know a thing or two about black holes.");
316             return results;
317         } else
318             throw new IllegalStateException("Harness failed to distribute threads among groups properly");
319     }
320 
321     public static void codecOutList_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, CodecOutputListBenchmark_jmhType l_codecoutputlistbenchmark0_G) throws Throwable {
322         long realTime = 0;
323         long operations = 0;
324         int rnd = (int)System.nanoTime();
325         int rndMask = startRndMask;
326         long time = 0;
327         int currentStride = 0;
328         do {
329             rnd = (rnd * 1664525 + 1013904223);
330             boolean sample = (rnd & rndMask) == 0;
331             if (sample) {
332                 time = System.nanoTime();
333             }
334             for (int b = 0; b < batchSize; b++) {
335                 if (control.volatileSpoiler) return;
336                 l_codecoutputlistbenchmark0_G.codecOutList();
337             }
338             if (sample) {
339                 buffer.add((System.nanoTime() - time) / opsPerInv);
340                 if (currentStride++ > targetSamples) {
341                     buffer.half();
342                     currentStride = 0;
343                     rndMask = (rndMask << 1) + 1;
344                 }
345             }
346             operations++;
347         } while(!control.isDone);
348         startRndMask = Math.max(startRndMask, rndMask);
349         result.realTime = realTime;
350         result.measuredOps = operations;
351     }
352 
353 
354     public BenchmarkTaskResult codecOutList_SingleShotTime(InfraControl control, ThreadParams threadParams) throws Throwable {
355         this.benchmarkParams = control.benchmarkParams;
356         this.iterationParams = control.iterationParams;
357         this.threadParams    = threadParams;
358         this.notifyControl   = control.notifyControl;
359         if (this.blackhole == null) {
360             this.blackhole = new Blackhole("Today's password is swordfish. I understand instantiating Blackholes directly is dangerous.");
361         }
362         if (threadParams.getSubgroupIndex() == 0) {
363             CodecOutputListBenchmark_jmhType l_codecoutputlistbenchmark0_G = _jmh_tryInit_f_codecoutputlistbenchmark0_G(control);
364 
365             control.preSetup();
366 
367 
368             notifyControl.startMeasurement = true;
369             RawResults res = new RawResults();
370             int batchSize = iterationParams.getBatchSize();
371             codecOutList_ss_jmhStub(control, res, benchmarkParams, iterationParams, threadParams, blackhole, notifyControl, startRndMask, batchSize, l_codecoutputlistbenchmark0_G);
372             control.preTearDown();
373 
374             if (control.isLastIteration()) {
375                 if (CodecOutputListBenchmark_jmhType.tearTrialMutexUpdater.compareAndSet(l_codecoutputlistbenchmark0_G, 0, 1)) {
376                     try {
377                         if (control.isFailing) throw new FailureAssistException();
378                         if (l_codecoutputlistbenchmark0_G.readyTrial) {
379                             l_codecoutputlistbenchmark0_G.destroy();
380                             l_codecoutputlistbenchmark0_G.readyTrial = false;
381                         }
382                     } catch (Throwable t) {
383                         control.isFailing = true;
384                         throw t;
385                     } finally {
386                         CodecOutputListBenchmark_jmhType.tearTrialMutexUpdater.set(l_codecoutputlistbenchmark0_G, 0);
387                     }
388                 } else {
389                     long l_codecoutputlistbenchmark0_G_backoff = 1;
390                     while (CodecOutputListBenchmark_jmhType.tearTrialMutexUpdater.get(l_codecoutputlistbenchmark0_G) == 1) {
391                         TimeUnit.MILLISECONDS.sleep(l_codecoutputlistbenchmark0_G_backoff);
392                         l_codecoutputlistbenchmark0_G_backoff = Math.max(1024, l_codecoutputlistbenchmark0_G_backoff * 2);
393                         if (control.isFailing) throw new FailureAssistException();
394                         if (Thread.interrupted()) throw new InterruptedException();
395                     }
396                 }
397                 synchronized(this.getClass()) {
398                     f_codecoutputlistbenchmark0_G = null;
399                 }
400             }
401             int opsPerInv = control.benchmarkParams.getOpsPerInvocation();
402             long totalOps = opsPerInv;
403             BenchmarkTaskResult results = new BenchmarkTaskResult(totalOps, totalOps);
404             results.add(new SingleShotResult(ResultRole.PRIMARY, "codecOutList", res.getTime(), benchmarkParams.getTimeUnit()));
405             this.blackhole.evaporate("Yes, I am Stephen Hawking, and know a thing or two about black holes.");
406             return results;
407         } else
408             throw new IllegalStateException("Harness failed to distribute threads among groups properly");
409     }
410 
411     public static void codecOutList_ss_jmhStub(InfraControl control, RawResults result, BenchmarkParams benchmarkParams, IterationParams iterationParams, ThreadParams threadParams, Blackhole blackhole, Control notifyControl, int startRndMask, int batchSize, CodecOutputListBenchmark_jmhType l_codecoutputlistbenchmark0_G) throws Throwable {
412         long realTime = 0;
413         result.startTime = System.nanoTime();
414         for (int b = 0; b < batchSize; b++) {
415             if (control.volatileSpoiler) return;
416             l_codecoutputlistbenchmark0_G.codecOutList();
417         }
418         result.stopTime = System.nanoTime();
419         result.realTime = realTime;
420     }
421 
422     
423     static volatile CodecOutputListBenchmark_jmhType f_codecoutputlistbenchmark0_G;
424     
425     CodecOutputListBenchmark_jmhType _jmh_tryInit_f_codecoutputlistbenchmark0_G(InfraControl control) throws Throwable {
426         CodecOutputListBenchmark_jmhType val = f_codecoutputlistbenchmark0_G;
427         if (val != null) {
428             return val;
429         }
430         synchronized(this.getClass()) {
431             try {
432             if (control.isFailing) throw new FailureAssistException();
433             val = f_codecoutputlistbenchmark0_G;
434             if (val != null) {
435                 return val;
436             }
437             val = new CodecOutputListBenchmark_jmhType();
438             Field f;
439             f = io.netty5.handler.codec.CodecOutputListBenchmark.class.getDeclaredField("elements");
440             f.setAccessible(true);
441             f.set(val, Integer.valueOf(control.getParam("elements")));
442             val.readyTrial = true;
443             f_codecoutputlistbenchmark0_G = val;
444             } catch (Throwable t) {
445                 control.isFailing = true;
446                 throw t;
447             }
448         }
449         return val;
450     }
451 
452 
453 }
454