View Javadoc
1   package io.netty5.handler.codec.http.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.http.jmh_generated.WriteBytesVsShortOrMediumBenchmark_jmhType;
36  public final class WriteBytesVsShortOrMediumBenchmark_chainedBytes2_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 chainedBytes2_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              WriteBytesVsShortOrMediumBenchmark_jmhType l_writebytesvsshortormediumbenchmark0_0 = _jmh_tryInit_f_writebytesvsshortormediumbenchmark0_0(control);
72  
73              control.preSetup();
74  
75  
76              control.announceWarmupReady();
77              while (control.warmupShouldWait) {
78                  blackhole.consume(l_writebytesvsshortormediumbenchmark0_0.chainedBytes2());
79                  res.allOps++;
80              }
81  
82              notifyControl.startMeasurement = true;
83              chainedBytes2_thrpt_jmhStub(control, res, benchmarkParams, iterationParams, threadParams, blackhole, notifyControl, startRndMask, l_writebytesvsshortormediumbenchmark0_0);
84              notifyControl.stopMeasurement = true;
85              control.announceWarmdownReady();
86              try {
87                  while (control.warmdownShouldWait) {
88                      blackhole.consume(l_writebytesvsshortormediumbenchmark0_0.chainedBytes2());
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                  f_writebytesvsshortormediumbenchmark0_0 = null;
98              }
99              res.allOps += res.measuredOps;
100             int batchSize = iterationParams.getBatchSize();
101             int opsPerInv = benchmarkParams.getOpsPerInvocation();
102             res.allOps *= opsPerInv;
103             res.allOps /= batchSize;
104             res.measuredOps *= opsPerInv;
105             res.measuredOps /= batchSize;
106             BenchmarkTaskResult results = new BenchmarkTaskResult((long)res.allOps, (long)res.measuredOps);
107             results.add(new ThroughputResult(ResultRole.PRIMARY, "chainedBytes2", res.measuredOps, res.getTime(), benchmarkParams.getTimeUnit()));
108             this.blackhole.evaporate("Yes, I am Stephen Hawking, and know a thing or two about black holes.");
109             return results;
110         } else
111             throw new IllegalStateException("Harness failed to distribute threads among groups properly");
112     }
113 
114     public static void chainedBytes2_thrpt_jmhStub(InfraControl control, RawResults result, BenchmarkParams benchmarkParams, IterationParams iterationParams, ThreadParams threadParams, Blackhole blackhole, Control notifyControl, int startRndMask, WriteBytesVsShortOrMediumBenchmark_jmhType l_writebytesvsshortormediumbenchmark0_0) throws Throwable {
115         long operations = 0;
116         long realTime = 0;
117         result.startTime = System.nanoTime();
118         do {
119             blackhole.consume(l_writebytesvsshortormediumbenchmark0_0.chainedBytes2());
120             operations++;
121         } while(!control.isDone);
122         result.stopTime = System.nanoTime();
123         result.realTime = realTime;
124         result.measuredOps = operations;
125     }
126 
127 
128     public BenchmarkTaskResult chainedBytes2_AverageTime(InfraControl control, ThreadParams threadParams) throws Throwable {
129         this.benchmarkParams = control.benchmarkParams;
130         this.iterationParams = control.iterationParams;
131         this.threadParams    = threadParams;
132         this.notifyControl   = control.notifyControl;
133         if (this.blackhole == null) {
134             this.blackhole = new Blackhole("Today's password is swordfish. I understand instantiating Blackholes directly is dangerous.");
135         }
136         if (threadParams.getSubgroupIndex() == 0) {
137             RawResults res = new RawResults();
138             WriteBytesVsShortOrMediumBenchmark_jmhType l_writebytesvsshortormediumbenchmark0_0 = _jmh_tryInit_f_writebytesvsshortormediumbenchmark0_0(control);
139 
140             control.preSetup();
141 
142 
143             control.announceWarmupReady();
144             while (control.warmupShouldWait) {
145                 blackhole.consume(l_writebytesvsshortormediumbenchmark0_0.chainedBytes2());
146                 res.allOps++;
147             }
148 
149             notifyControl.startMeasurement = true;
150             chainedBytes2_avgt_jmhStub(control, res, benchmarkParams, iterationParams, threadParams, blackhole, notifyControl, startRndMask, l_writebytesvsshortormediumbenchmark0_0);
151             notifyControl.stopMeasurement = true;
152             control.announceWarmdownReady();
153             try {
154                 while (control.warmdownShouldWait) {
155                     blackhole.consume(l_writebytesvsshortormediumbenchmark0_0.chainedBytes2());
156                     res.allOps++;
157                 }
158             } catch (Throwable e) {
159                 if (!(e instanceof InterruptedException)) throw e;
160             }
161             control.preTearDown();
162 
163             if (control.isLastIteration()) {
164                 f_writebytesvsshortormediumbenchmark0_0 = null;
165             }
166             res.allOps += res.measuredOps;
167             int batchSize = iterationParams.getBatchSize();
168             int opsPerInv = benchmarkParams.getOpsPerInvocation();
169             res.allOps *= opsPerInv;
170             res.allOps /= batchSize;
171             res.measuredOps *= opsPerInv;
172             res.measuredOps /= batchSize;
173             BenchmarkTaskResult results = new BenchmarkTaskResult((long)res.allOps, (long)res.measuredOps);
174             results.add(new AverageTimeResult(ResultRole.PRIMARY, "chainedBytes2", res.measuredOps, res.getTime(), benchmarkParams.getTimeUnit()));
175             this.blackhole.evaporate("Yes, I am Stephen Hawking, and know a thing or two about black holes.");
176             return results;
177         } else
178             throw new IllegalStateException("Harness failed to distribute threads among groups properly");
179     }
180 
181     public static void chainedBytes2_avgt_jmhStub(InfraControl control, RawResults result, BenchmarkParams benchmarkParams, IterationParams iterationParams, ThreadParams threadParams, Blackhole blackhole, Control notifyControl, int startRndMask, WriteBytesVsShortOrMediumBenchmark_jmhType l_writebytesvsshortormediumbenchmark0_0) throws Throwable {
182         long operations = 0;
183         long realTime = 0;
184         result.startTime = System.nanoTime();
185         do {
186             blackhole.consume(l_writebytesvsshortormediumbenchmark0_0.chainedBytes2());
187             operations++;
188         } while(!control.isDone);
189         result.stopTime = System.nanoTime();
190         result.realTime = realTime;
191         result.measuredOps = operations;
192     }
193 
194 
195     public BenchmarkTaskResult chainedBytes2_SampleTime(InfraControl control, ThreadParams threadParams) throws Throwable {
196         this.benchmarkParams = control.benchmarkParams;
197         this.iterationParams = control.iterationParams;
198         this.threadParams    = threadParams;
199         this.notifyControl   = control.notifyControl;
200         if (this.blackhole == null) {
201             this.blackhole = new Blackhole("Today's password is swordfish. I understand instantiating Blackholes directly is dangerous.");
202         }
203         if (threadParams.getSubgroupIndex() == 0) {
204             RawResults res = new RawResults();
205             WriteBytesVsShortOrMediumBenchmark_jmhType l_writebytesvsshortormediumbenchmark0_0 = _jmh_tryInit_f_writebytesvsshortormediumbenchmark0_0(control);
206 
207             control.preSetup();
208 
209 
210             control.announceWarmupReady();
211             while (control.warmupShouldWait) {
212                 blackhole.consume(l_writebytesvsshortormediumbenchmark0_0.chainedBytes2());
213                 res.allOps++;
214             }
215 
216             notifyControl.startMeasurement = true;
217             int targetSamples = (int) (control.getDuration(TimeUnit.MILLISECONDS) * 20); // at max, 20 timestamps per millisecond
218             int batchSize = iterationParams.getBatchSize();
219             int opsPerInv = benchmarkParams.getOpsPerInvocation();
220             SampleBuffer buffer = new SampleBuffer();
221             chainedBytes2_sample_jmhStub(control, res, benchmarkParams, iterationParams, threadParams, blackhole, notifyControl, startRndMask, buffer, targetSamples, opsPerInv, batchSize, l_writebytesvsshortormediumbenchmark0_0);
222             notifyControl.stopMeasurement = true;
223             control.announceWarmdownReady();
224             try {
225                 while (control.warmdownShouldWait) {
226                     blackhole.consume(l_writebytesvsshortormediumbenchmark0_0.chainedBytes2());
227                     res.allOps++;
228                 }
229             } catch (Throwable e) {
230                 if (!(e instanceof InterruptedException)) throw e;
231             }
232             control.preTearDown();
233 
234             if (control.isLastIteration()) {
235                 f_writebytesvsshortormediumbenchmark0_0 = null;
236             }
237             res.allOps += res.measuredOps * batchSize;
238             res.allOps *= opsPerInv;
239             res.allOps /= batchSize;
240             res.measuredOps *= opsPerInv;
241             BenchmarkTaskResult results = new BenchmarkTaskResult((long)res.allOps, (long)res.measuredOps);
242             results.add(new SampleTimeResult(ResultRole.PRIMARY, "chainedBytes2", buffer, benchmarkParams.getTimeUnit()));
243             this.blackhole.evaporate("Yes, I am Stephen Hawking, and know a thing or two about black holes.");
244             return results;
245         } else
246             throw new IllegalStateException("Harness failed to distribute threads among groups properly");
247     }
248 
249     public static void chainedBytes2_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, WriteBytesVsShortOrMediumBenchmark_jmhType l_writebytesvsshortormediumbenchmark0_0) throws Throwable {
250         long realTime = 0;
251         long operations = 0;
252         int rnd = (int)System.nanoTime();
253         int rndMask = startRndMask;
254         long time = 0;
255         int currentStride = 0;
256         do {
257             rnd = (rnd * 1664525 + 1013904223);
258             boolean sample = (rnd & rndMask) == 0;
259             if (sample) {
260                 time = System.nanoTime();
261             }
262             for (int b = 0; b < batchSize; b++) {
263                 if (control.volatileSpoiler) return;
264                 blackhole.consume(l_writebytesvsshortormediumbenchmark0_0.chainedBytes2());
265             }
266             if (sample) {
267                 buffer.add((System.nanoTime() - time) / opsPerInv);
268                 if (currentStride++ > targetSamples) {
269                     buffer.half();
270                     currentStride = 0;
271                     rndMask = (rndMask << 1) + 1;
272                 }
273             }
274             operations++;
275         } while(!control.isDone);
276         startRndMask = Math.max(startRndMask, rndMask);
277         result.realTime = realTime;
278         result.measuredOps = operations;
279     }
280 
281 
282     public BenchmarkTaskResult chainedBytes2_SingleShotTime(InfraControl control, ThreadParams threadParams) throws Throwable {
283         this.benchmarkParams = control.benchmarkParams;
284         this.iterationParams = control.iterationParams;
285         this.threadParams    = threadParams;
286         this.notifyControl   = control.notifyControl;
287         if (this.blackhole == null) {
288             this.blackhole = new Blackhole("Today's password is swordfish. I understand instantiating Blackholes directly is dangerous.");
289         }
290         if (threadParams.getSubgroupIndex() == 0) {
291             WriteBytesVsShortOrMediumBenchmark_jmhType l_writebytesvsshortormediumbenchmark0_0 = _jmh_tryInit_f_writebytesvsshortormediumbenchmark0_0(control);
292 
293             control.preSetup();
294 
295 
296             notifyControl.startMeasurement = true;
297             RawResults res = new RawResults();
298             int batchSize = iterationParams.getBatchSize();
299             chainedBytes2_ss_jmhStub(control, res, benchmarkParams, iterationParams, threadParams, blackhole, notifyControl, startRndMask, batchSize, l_writebytesvsshortormediumbenchmark0_0);
300             control.preTearDown();
301 
302             if (control.isLastIteration()) {
303                 f_writebytesvsshortormediumbenchmark0_0 = null;
304             }
305             int opsPerInv = control.benchmarkParams.getOpsPerInvocation();
306             long totalOps = opsPerInv;
307             BenchmarkTaskResult results = new BenchmarkTaskResult(totalOps, totalOps);
308             results.add(new SingleShotResult(ResultRole.PRIMARY, "chainedBytes2", res.getTime(), benchmarkParams.getTimeUnit()));
309             this.blackhole.evaporate("Yes, I am Stephen Hawking, and know a thing or two about black holes.");
310             return results;
311         } else
312             throw new IllegalStateException("Harness failed to distribute threads among groups properly");
313     }
314 
315     public static void chainedBytes2_ss_jmhStub(InfraControl control, RawResults result, BenchmarkParams benchmarkParams, IterationParams iterationParams, ThreadParams threadParams, Blackhole blackhole, Control notifyControl, int startRndMask, int batchSize, WriteBytesVsShortOrMediumBenchmark_jmhType l_writebytesvsshortormediumbenchmark0_0) throws Throwable {
316         long realTime = 0;
317         result.startTime = System.nanoTime();
318         for (int b = 0; b < batchSize; b++) {
319             if (control.volatileSpoiler) return;
320             blackhole.consume(l_writebytesvsshortormediumbenchmark0_0.chainedBytes2());
321         }
322         result.stopTime = System.nanoTime();
323         result.realTime = realTime;
324     }
325 
326     
327     WriteBytesVsShortOrMediumBenchmark_jmhType f_writebytesvsshortormediumbenchmark0_0;
328     
329     WriteBytesVsShortOrMediumBenchmark_jmhType _jmh_tryInit_f_writebytesvsshortormediumbenchmark0_0(InfraControl control) throws Throwable {
330         if (control.isFailing) throw new FailureAssistException();
331         WriteBytesVsShortOrMediumBenchmark_jmhType val = f_writebytesvsshortormediumbenchmark0_0;
332         if (val == null) {
333             val = new WriteBytesVsShortOrMediumBenchmark_jmhType();
334             f_writebytesvsshortormediumbenchmark0_0 = val;
335         }
336         return val;
337     }
338 
339 
340 }
341