View Javadoc
1   package org.eclipse.jgit.benchmarks.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.eclipse.jgit.benchmarks.generated.SimpleLruCacheBenchmark_jmhType;
36  public final class SimpleLruCacheBenchmark_readwrite_jmhTest {
37  
38      boolean p000, p001, p002, p003, p004, p005, p006, p007, p008, p009, p010, p011, p012, p013, p014, p015;
39      boolean p016, p017, p018, p019, p020, p021, p022, p023, p024, p025, p026, p027, p028, p029, p030, p031;
40      boolean p032, p033, p034, p035, p036, p037, p038, p039, p040, p041, p042, p043, p044, p045, p046, p047;
41      boolean p048, p049, p050, p051, p052, p053, p054, p055, p056, p057, p058, p059, p060, p061, p062, p063;
42      boolean p064, p065, p066, p067, p068, p069, p070, p071, p072, p073, p074, p075, p076, p077, p078, p079;
43      boolean p080, p081, p082, p083, p084, p085, p086, p087, p088, p089, p090, p091, p092, p093, p094, p095;
44      boolean p096, p097, p098, p099, p100, p101, p102, p103, p104, p105, p106, p107, p108, p109, p110, p111;
45      boolean p112, p113, p114, p115, p116, p117, p118, p119, p120, p121, p122, p123, p124, p125, p126, p127;
46      boolean p128, p129, p130, p131, p132, p133, p134, p135, p136, p137, p138, p139, p140, p141, p142, p143;
47      boolean p144, p145, p146, p147, p148, p149, p150, p151, p152, p153, p154, p155, p156, p157, p158, p159;
48      boolean p160, p161, p162, p163, p164, p165, p166, p167, p168, p169, p170, p171, p172, p173, p174, p175;
49      boolean p176, p177, p178, p179, p180, p181, p182, p183, p184, p185, p186, p187, p188, p189, p190, p191;
50      boolean p192, p193, p194, p195, p196, p197, p198, p199, p200, p201, p202, p203, p204, p205, p206, p207;
51      boolean p208, p209, p210, p211, p212, p213, p214, p215, p216, p217, p218, p219, p220, p221, p222, p223;
52      boolean p224, p225, p226, p227, p228, p229, p230, p231, p232, p233, p234, p235, p236, p237, p238, p239;
53      boolean 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 readwrite_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              SimpleLruCacheBenchmark_jmhType l_simplelrucachebenchmark0_G = _jmh_tryInit_f_simplelrucachebenchmark0_G(control);
72  
73              control.preSetup();
74  
75  
76              control.announceWarmupReady();
77              while (control.warmupShouldWait) {
78                  blackhole.consume(l_simplelrucachebenchmark0_G.testCacheRead());
79                  res.allOps++;
80              }
81  
82              notifyControl.startMeasurement = true;
83              testCacheRead_thrpt_jmhStub(control, res, benchmarkParams, iterationParams, threadParams, blackhole, notifyControl, startRndMask, l_simplelrucachebenchmark0_G);
84              notifyControl.stopMeasurement = true;
85              control.announceWarmdownReady();
86              try {
87                  while (control.warmdownShouldWait) {
88                      blackhole.consume(l_simplelrucachebenchmark0_G.testCacheRead());
89                      res.allOps++;
90                  }
91                  control.preTearDown();
92              } catch (InterruptedException ie) {
93                  control.preTearDownForce();
94              }
95  
96              if (control.isLastIteration()) {
97                  if (SimpleLruCacheBenchmark_jmhType.tearTrialMutexUpdater.compareAndSet(l_simplelrucachebenchmark0_G, 0, 1)) {
98                      try {
99                          if (control.isFailing) throw new FailureAssistException();
100                         if (l_simplelrucachebenchmark0_G.readyTrial) {
101                             l_simplelrucachebenchmark0_G.teardown();
102                             l_simplelrucachebenchmark0_G.readyTrial = false;
103                         }
104                     } catch (Throwable t) {
105                         control.isFailing = true;
106                         throw t;
107                     } finally {
108                         SimpleLruCacheBenchmark_jmhType.tearTrialMutexUpdater.set(l_simplelrucachebenchmark0_G, 0);
109                     }
110                 } else {
111                     long l_simplelrucachebenchmark0_G_backoff = 1;
112                     while (SimpleLruCacheBenchmark_jmhType.tearTrialMutexUpdater.get(l_simplelrucachebenchmark0_G) == 1) {
113                         TimeUnit.MILLISECONDS.sleep(l_simplelrucachebenchmark0_G_backoff);
114                         l_simplelrucachebenchmark0_G_backoff = Math.max(1024, l_simplelrucachebenchmark0_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_simplelrucachebenchmark0_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(res.allOps, res.measuredOps);
131             results.add(new ThroughputResult(ResultRole.PRIMARY, "readwrite", res.measuredOps, res.getTime(), benchmarkParams.getTimeUnit()));
132             results.add(new ThroughputResult(ResultRole.SECONDARY, "testCacheRead", 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         if (threadParams.getSubgroupIndex() == 1) {
137             RawResults res = new RawResults();
138             SimpleLruCacheBenchmark_jmhType l_simplelrucachebenchmark0_G = _jmh_tryInit_f_simplelrucachebenchmark0_G(control);
139 
140             control.preSetup();
141 
142 
143             control.announceWarmupReady();
144             while (control.warmupShouldWait) {
145                 blackhole.consume(l_simplelrucachebenchmark0_G.testCacheWrite());
146                 res.allOps++;
147             }
148 
149             notifyControl.startMeasurement = true;
150             testCacheWrite_thrpt_jmhStub(control, res, benchmarkParams, iterationParams, threadParams, blackhole, notifyControl, startRndMask, l_simplelrucachebenchmark0_G);
151             notifyControl.stopMeasurement = true;
152             control.announceWarmdownReady();
153             try {
154                 while (control.warmdownShouldWait) {
155                     blackhole.consume(l_simplelrucachebenchmark0_G.testCacheWrite());
156                     res.allOps++;
157                 }
158                 control.preTearDown();
159             } catch (InterruptedException ie) {
160                 control.preTearDownForce();
161             }
162 
163             if (control.isLastIteration()) {
164                 if (SimpleLruCacheBenchmark_jmhType.tearTrialMutexUpdater.compareAndSet(l_simplelrucachebenchmark0_G, 0, 1)) {
165                     try {
166                         if (control.isFailing) throw new FailureAssistException();
167                         if (l_simplelrucachebenchmark0_G.readyTrial) {
168                             l_simplelrucachebenchmark0_G.teardown();
169                             l_simplelrucachebenchmark0_G.readyTrial = false;
170                         }
171                     } catch (Throwable t) {
172                         control.isFailing = true;
173                         throw t;
174                     } finally {
175                         SimpleLruCacheBenchmark_jmhType.tearTrialMutexUpdater.set(l_simplelrucachebenchmark0_G, 0);
176                     }
177                 } else {
178                     long l_simplelrucachebenchmark0_G_backoff = 1;
179                     while (SimpleLruCacheBenchmark_jmhType.tearTrialMutexUpdater.get(l_simplelrucachebenchmark0_G) == 1) {
180                         TimeUnit.MILLISECONDS.sleep(l_simplelrucachebenchmark0_G_backoff);
181                         l_simplelrucachebenchmark0_G_backoff = Math.max(1024, l_simplelrucachebenchmark0_G_backoff * 2);
182                         if (control.isFailing) throw new FailureAssistException();
183                         if (Thread.interrupted()) throw new InterruptedException();
184                     }
185                 }
186                 synchronized(this.getClass()) {
187                     f_simplelrucachebenchmark0_G = null;
188                 }
189             }
190             res.allOps += res.measuredOps;
191             int batchSize = iterationParams.getBatchSize();
192             int opsPerInv = benchmarkParams.getOpsPerInvocation();
193             res.allOps *= opsPerInv;
194             res.allOps /= batchSize;
195             res.measuredOps *= opsPerInv;
196             res.measuredOps /= batchSize;
197             BenchmarkTaskResult results = new BenchmarkTaskResult(res.allOps, res.measuredOps);
198             results.add(new ThroughputResult(ResultRole.PRIMARY, "readwrite", res.measuredOps, res.getTime(), benchmarkParams.getTimeUnit()));
199             results.add(new ThroughputResult(ResultRole.SECONDARY, "testCacheWrite", res.measuredOps, res.getTime(), benchmarkParams.getTimeUnit()));
200             this.blackhole.evaporate("Yes, I am Stephen Hawking, and know a thing or two about black holes.");
201             return results;
202         } else
203             throw new IllegalStateException("Harness failed to distribute threads among groups properly");
204     }
205 
206     public static void testCacheRead_thrpt_jmhStub(InfraControl control, RawResults result, BenchmarkParams benchmarkParams, IterationParams iterationParams, ThreadParams threadParams, Blackhole blackhole, Control notifyControl, int startRndMask, SimpleLruCacheBenchmark_jmhType l_simplelrucachebenchmark0_G) throws Throwable {
207         long operations = 0;
208         long realTime = 0;
209         result.startTime = System.nanoTime();
210         do {
211             blackhole.consume(l_simplelrucachebenchmark0_G.testCacheRead());
212             operations++;
213         } while(!control.isDone);
214         result.stopTime = System.nanoTime();
215         result.realTime = realTime;
216         result.measuredOps = operations;
217     }
218 
219     public static void testCacheWrite_thrpt_jmhStub(InfraControl control, RawResults result, BenchmarkParams benchmarkParams, IterationParams iterationParams, ThreadParams threadParams, Blackhole blackhole, Control notifyControl, int startRndMask, SimpleLruCacheBenchmark_jmhType l_simplelrucachebenchmark0_G) throws Throwable {
220         long operations = 0;
221         long realTime = 0;
222         result.startTime = System.nanoTime();
223         do {
224             blackhole.consume(l_simplelrucachebenchmark0_G.testCacheWrite());
225             operations++;
226         } while(!control.isDone);
227         result.stopTime = System.nanoTime();
228         result.realTime = realTime;
229         result.measuredOps = operations;
230     }
231 
232 
233     public BenchmarkTaskResult readwrite_AverageTime(InfraControl control, ThreadParams threadParams) throws Throwable {
234         this.benchmarkParams = control.benchmarkParams;
235         this.iterationParams = control.iterationParams;
236         this.threadParams    = threadParams;
237         this.notifyControl   = control.notifyControl;
238         if (this.blackhole == null) {
239             this.blackhole = new Blackhole("Today's password is swordfish. I understand instantiating Blackholes directly is dangerous.");
240         }
241         if (threadParams.getSubgroupIndex() == 0) {
242             RawResults res = new RawResults();
243             SimpleLruCacheBenchmark_jmhType l_simplelrucachebenchmark0_G = _jmh_tryInit_f_simplelrucachebenchmark0_G(control);
244 
245             control.preSetup();
246 
247 
248             control.announceWarmupReady();
249             while (control.warmupShouldWait) {
250                 blackhole.consume(l_simplelrucachebenchmark0_G.testCacheRead());
251                 res.allOps++;
252             }
253 
254             notifyControl.startMeasurement = true;
255             testCacheRead_avgt_jmhStub(control, res, benchmarkParams, iterationParams, threadParams, blackhole, notifyControl, startRndMask, l_simplelrucachebenchmark0_G);
256             notifyControl.stopMeasurement = true;
257             control.announceWarmdownReady();
258             try {
259                 while (control.warmdownShouldWait) {
260                     blackhole.consume(l_simplelrucachebenchmark0_G.testCacheRead());
261                     res.allOps++;
262                 }
263                 control.preTearDown();
264             } catch (InterruptedException ie) {
265                 control.preTearDownForce();
266             }
267 
268             if (control.isLastIteration()) {
269                 if (SimpleLruCacheBenchmark_jmhType.tearTrialMutexUpdater.compareAndSet(l_simplelrucachebenchmark0_G, 0, 1)) {
270                     try {
271                         if (control.isFailing) throw new FailureAssistException();
272                         if (l_simplelrucachebenchmark0_G.readyTrial) {
273                             l_simplelrucachebenchmark0_G.teardown();
274                             l_simplelrucachebenchmark0_G.readyTrial = false;
275                         }
276                     } catch (Throwable t) {
277                         control.isFailing = true;
278                         throw t;
279                     } finally {
280                         SimpleLruCacheBenchmark_jmhType.tearTrialMutexUpdater.set(l_simplelrucachebenchmark0_G, 0);
281                     }
282                 } else {
283                     long l_simplelrucachebenchmark0_G_backoff = 1;
284                     while (SimpleLruCacheBenchmark_jmhType.tearTrialMutexUpdater.get(l_simplelrucachebenchmark0_G) == 1) {
285                         TimeUnit.MILLISECONDS.sleep(l_simplelrucachebenchmark0_G_backoff);
286                         l_simplelrucachebenchmark0_G_backoff = Math.max(1024, l_simplelrucachebenchmark0_G_backoff * 2);
287                         if (control.isFailing) throw new FailureAssistException();
288                         if (Thread.interrupted()) throw new InterruptedException();
289                     }
290                 }
291                 synchronized(this.getClass()) {
292                     f_simplelrucachebenchmark0_G = null;
293                 }
294             }
295             res.allOps += res.measuredOps;
296             int batchSize = iterationParams.getBatchSize();
297             int opsPerInv = benchmarkParams.getOpsPerInvocation();
298             res.allOps *= opsPerInv;
299             res.allOps /= batchSize;
300             res.measuredOps *= opsPerInv;
301             res.measuredOps /= batchSize;
302             BenchmarkTaskResult results = new BenchmarkTaskResult(res.allOps, res.measuredOps);
303             results.add(new AverageTimeResult(ResultRole.PRIMARY, "readwrite", res.measuredOps, res.getTime(), benchmarkParams.getTimeUnit()));
304             results.add(new AverageTimeResult(ResultRole.SECONDARY, "testCacheRead", res.measuredOps, res.getTime(), benchmarkParams.getTimeUnit()));
305             this.blackhole.evaporate("Yes, I am Stephen Hawking, and know a thing or two about black holes.");
306             return results;
307         } else
308         if (threadParams.getSubgroupIndex() == 1) {
309             RawResults res = new RawResults();
310             SimpleLruCacheBenchmark_jmhType l_simplelrucachebenchmark0_G = _jmh_tryInit_f_simplelrucachebenchmark0_G(control);
311 
312             control.preSetup();
313 
314 
315             control.announceWarmupReady();
316             while (control.warmupShouldWait) {
317                 blackhole.consume(l_simplelrucachebenchmark0_G.testCacheWrite());
318                 res.allOps++;
319             }
320 
321             notifyControl.startMeasurement = true;
322             testCacheWrite_avgt_jmhStub(control, res, benchmarkParams, iterationParams, threadParams, blackhole, notifyControl, startRndMask, l_simplelrucachebenchmark0_G);
323             notifyControl.stopMeasurement = true;
324             control.announceWarmdownReady();
325             try {
326                 while (control.warmdownShouldWait) {
327                     blackhole.consume(l_simplelrucachebenchmark0_G.testCacheWrite());
328                     res.allOps++;
329                 }
330                 control.preTearDown();
331             } catch (InterruptedException ie) {
332                 control.preTearDownForce();
333             }
334 
335             if (control.isLastIteration()) {
336                 if (SimpleLruCacheBenchmark_jmhType.tearTrialMutexUpdater.compareAndSet(l_simplelrucachebenchmark0_G, 0, 1)) {
337                     try {
338                         if (control.isFailing) throw new FailureAssistException();
339                         if (l_simplelrucachebenchmark0_G.readyTrial) {
340                             l_simplelrucachebenchmark0_G.teardown();
341                             l_simplelrucachebenchmark0_G.readyTrial = false;
342                         }
343                     } catch (Throwable t) {
344                         control.isFailing = true;
345                         throw t;
346                     } finally {
347                         SimpleLruCacheBenchmark_jmhType.tearTrialMutexUpdater.set(l_simplelrucachebenchmark0_G, 0);
348                     }
349                 } else {
350                     long l_simplelrucachebenchmark0_G_backoff = 1;
351                     while (SimpleLruCacheBenchmark_jmhType.tearTrialMutexUpdater.get(l_simplelrucachebenchmark0_G) == 1) {
352                         TimeUnit.MILLISECONDS.sleep(l_simplelrucachebenchmark0_G_backoff);
353                         l_simplelrucachebenchmark0_G_backoff = Math.max(1024, l_simplelrucachebenchmark0_G_backoff * 2);
354                         if (control.isFailing) throw new FailureAssistException();
355                         if (Thread.interrupted()) throw new InterruptedException();
356                     }
357                 }
358                 synchronized(this.getClass()) {
359                     f_simplelrucachebenchmark0_G = null;
360                 }
361             }
362             res.allOps += res.measuredOps;
363             int batchSize = iterationParams.getBatchSize();
364             int opsPerInv = benchmarkParams.getOpsPerInvocation();
365             res.allOps *= opsPerInv;
366             res.allOps /= batchSize;
367             res.measuredOps *= opsPerInv;
368             res.measuredOps /= batchSize;
369             BenchmarkTaskResult results = new BenchmarkTaskResult(res.allOps, res.measuredOps);
370             results.add(new AverageTimeResult(ResultRole.PRIMARY, "readwrite", res.measuredOps, res.getTime(), benchmarkParams.getTimeUnit()));
371             results.add(new AverageTimeResult(ResultRole.SECONDARY, "testCacheWrite", res.measuredOps, res.getTime(), benchmarkParams.getTimeUnit()));
372             this.blackhole.evaporate("Yes, I am Stephen Hawking, and know a thing or two about black holes.");
373             return results;
374         } else
375             throw new IllegalStateException("Harness failed to distribute threads among groups properly");
376     }
377 
378     public static void testCacheRead_avgt_jmhStub(InfraControl control, RawResults result, BenchmarkParams benchmarkParams, IterationParams iterationParams, ThreadParams threadParams, Blackhole blackhole, Control notifyControl, int startRndMask, SimpleLruCacheBenchmark_jmhType l_simplelrucachebenchmark0_G) throws Throwable {
379         long operations = 0;
380         long realTime = 0;
381         result.startTime = System.nanoTime();
382         do {
383             blackhole.consume(l_simplelrucachebenchmark0_G.testCacheRead());
384             operations++;
385         } while(!control.isDone);
386         result.stopTime = System.nanoTime();
387         result.realTime = realTime;
388         result.measuredOps = operations;
389     }
390 
391     public static void testCacheWrite_avgt_jmhStub(InfraControl control, RawResults result, BenchmarkParams benchmarkParams, IterationParams iterationParams, ThreadParams threadParams, Blackhole blackhole, Control notifyControl, int startRndMask, SimpleLruCacheBenchmark_jmhType l_simplelrucachebenchmark0_G) throws Throwable {
392         long operations = 0;
393         long realTime = 0;
394         result.startTime = System.nanoTime();
395         do {
396             blackhole.consume(l_simplelrucachebenchmark0_G.testCacheWrite());
397             operations++;
398         } while(!control.isDone);
399         result.stopTime = System.nanoTime();
400         result.realTime = realTime;
401         result.measuredOps = operations;
402     }
403 
404 
405     public BenchmarkTaskResult readwrite_SampleTime(InfraControl control, ThreadParams threadParams) throws Throwable {
406         this.benchmarkParams = control.benchmarkParams;
407         this.iterationParams = control.iterationParams;
408         this.threadParams    = threadParams;
409         this.notifyControl   = control.notifyControl;
410         if (this.blackhole == null) {
411             this.blackhole = new Blackhole("Today's password is swordfish. I understand instantiating Blackholes directly is dangerous.");
412         }
413         if (threadParams.getSubgroupIndex() == 0) {
414             RawResults res = new RawResults();
415             SimpleLruCacheBenchmark_jmhType l_simplelrucachebenchmark0_G = _jmh_tryInit_f_simplelrucachebenchmark0_G(control);
416 
417             control.preSetup();
418 
419 
420             control.announceWarmupReady();
421             while (control.warmupShouldWait) {
422                 blackhole.consume(l_simplelrucachebenchmark0_G.testCacheRead());
423                 res.allOps++;
424             }
425 
426             notifyControl.startMeasurement = true;
427             int targetSamples = (int) (control.getDuration(TimeUnit.MILLISECONDS) * 20); // at max, 20 timestamps per millisecond
428             int batchSize = iterationParams.getBatchSize();
429             int opsPerInv = benchmarkParams.getOpsPerInvocation();
430             SampleBuffer buffer = new SampleBuffer();
431             testCacheRead_sample_jmhStub(control, res, benchmarkParams, iterationParams, threadParams, blackhole, notifyControl, startRndMask, buffer, targetSamples, opsPerInv, batchSize, l_simplelrucachebenchmark0_G);
432             notifyControl.stopMeasurement = true;
433             control.announceWarmdownReady();
434             try {
435                 while (control.warmdownShouldWait) {
436                     blackhole.consume(l_simplelrucachebenchmark0_G.testCacheRead());
437                     res.allOps++;
438                 }
439                 control.preTearDown();
440             } catch (InterruptedException ie) {
441                 control.preTearDownForce();
442             }
443 
444             if (control.isLastIteration()) {
445                 if (SimpleLruCacheBenchmark_jmhType.tearTrialMutexUpdater.compareAndSet(l_simplelrucachebenchmark0_G, 0, 1)) {
446                     try {
447                         if (control.isFailing) throw new FailureAssistException();
448                         if (l_simplelrucachebenchmark0_G.readyTrial) {
449                             l_simplelrucachebenchmark0_G.teardown();
450                             l_simplelrucachebenchmark0_G.readyTrial = false;
451                         }
452                     } catch (Throwable t) {
453                         control.isFailing = true;
454                         throw t;
455                     } finally {
456                         SimpleLruCacheBenchmark_jmhType.tearTrialMutexUpdater.set(l_simplelrucachebenchmark0_G, 0);
457                     }
458                 } else {
459                     long l_simplelrucachebenchmark0_G_backoff = 1;
460                     while (SimpleLruCacheBenchmark_jmhType.tearTrialMutexUpdater.get(l_simplelrucachebenchmark0_G) == 1) {
461                         TimeUnit.MILLISECONDS.sleep(l_simplelrucachebenchmark0_G_backoff);
462                         l_simplelrucachebenchmark0_G_backoff = Math.max(1024, l_simplelrucachebenchmark0_G_backoff * 2);
463                         if (control.isFailing) throw new FailureAssistException();
464                         if (Thread.interrupted()) throw new InterruptedException();
465                     }
466                 }
467                 synchronized(this.getClass()) {
468                     f_simplelrucachebenchmark0_G = null;
469                 }
470             }
471             res.allOps += res.measuredOps * batchSize;
472             res.allOps *= opsPerInv;
473             res.allOps /= batchSize;
474             res.measuredOps *= opsPerInv;
475             BenchmarkTaskResult results = new BenchmarkTaskResult(res.allOps, res.measuredOps);
476             results.add(new SampleTimeResult(ResultRole.PRIMARY, "readwrite", buffer, benchmarkParams.getTimeUnit()));
477             results.add(new SampleTimeResult(ResultRole.SECONDARY, "testCacheRead", buffer, benchmarkParams.getTimeUnit()));
478             this.blackhole.evaporate("Yes, I am Stephen Hawking, and know a thing or two about black holes.");
479             return results;
480         } else
481         if (threadParams.getSubgroupIndex() == 1) {
482             RawResults res = new RawResults();
483             SimpleLruCacheBenchmark_jmhType l_simplelrucachebenchmark0_G = _jmh_tryInit_f_simplelrucachebenchmark0_G(control);
484 
485             control.preSetup();
486 
487 
488             control.announceWarmupReady();
489             while (control.warmupShouldWait) {
490                 blackhole.consume(l_simplelrucachebenchmark0_G.testCacheWrite());
491                 res.allOps++;
492             }
493 
494             notifyControl.startMeasurement = true;
495             int targetSamples = (int) (control.getDuration(TimeUnit.MILLISECONDS) * 20); // at max, 20 timestamps per millisecond
496             int batchSize = iterationParams.getBatchSize();
497             int opsPerInv = benchmarkParams.getOpsPerInvocation();
498             SampleBuffer buffer = new SampleBuffer();
499             testCacheWrite_sample_jmhStub(control, res, benchmarkParams, iterationParams, threadParams, blackhole, notifyControl, startRndMask, buffer, targetSamples, opsPerInv, batchSize, l_simplelrucachebenchmark0_G);
500             notifyControl.stopMeasurement = true;
501             control.announceWarmdownReady();
502             try {
503                 while (control.warmdownShouldWait) {
504                     blackhole.consume(l_simplelrucachebenchmark0_G.testCacheWrite());
505                     res.allOps++;
506                 }
507                 control.preTearDown();
508             } catch (InterruptedException ie) {
509                 control.preTearDownForce();
510             }
511 
512             if (control.isLastIteration()) {
513                 if (SimpleLruCacheBenchmark_jmhType.tearTrialMutexUpdater.compareAndSet(l_simplelrucachebenchmark0_G, 0, 1)) {
514                     try {
515                         if (control.isFailing) throw new FailureAssistException();
516                         if (l_simplelrucachebenchmark0_G.readyTrial) {
517                             l_simplelrucachebenchmark0_G.teardown();
518                             l_simplelrucachebenchmark0_G.readyTrial = false;
519                         }
520                     } catch (Throwable t) {
521                         control.isFailing = true;
522                         throw t;
523                     } finally {
524                         SimpleLruCacheBenchmark_jmhType.tearTrialMutexUpdater.set(l_simplelrucachebenchmark0_G, 0);
525                     }
526                 } else {
527                     long l_simplelrucachebenchmark0_G_backoff = 1;
528                     while (SimpleLruCacheBenchmark_jmhType.tearTrialMutexUpdater.get(l_simplelrucachebenchmark0_G) == 1) {
529                         TimeUnit.MILLISECONDS.sleep(l_simplelrucachebenchmark0_G_backoff);
530                         l_simplelrucachebenchmark0_G_backoff = Math.max(1024, l_simplelrucachebenchmark0_G_backoff * 2);
531                         if (control.isFailing) throw new FailureAssistException();
532                         if (Thread.interrupted()) throw new InterruptedException();
533                     }
534                 }
535                 synchronized(this.getClass()) {
536                     f_simplelrucachebenchmark0_G = null;
537                 }
538             }
539             res.allOps += res.measuredOps * batchSize;
540             res.allOps *= opsPerInv;
541             res.allOps /= batchSize;
542             res.measuredOps *= opsPerInv;
543             BenchmarkTaskResult results = new BenchmarkTaskResult(res.allOps, res.measuredOps);
544             results.add(new SampleTimeResult(ResultRole.PRIMARY, "readwrite", buffer, benchmarkParams.getTimeUnit()));
545             results.add(new SampleTimeResult(ResultRole.SECONDARY, "testCacheWrite", buffer, benchmarkParams.getTimeUnit()));
546             this.blackhole.evaporate("Yes, I am Stephen Hawking, and know a thing or two about black holes.");
547             return results;
548         } else
549             throw new IllegalStateException("Harness failed to distribute threads among groups properly");
550     }
551 
552     public static void testCacheRead_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, SimpleLruCacheBenchmark_jmhType l_simplelrucachebenchmark0_G) throws Throwable {
553         long realTime = 0;
554         long operations = 0;
555         int rnd = (int)System.nanoTime();
556         int rndMask = startRndMask;
557         long time = 0;
558         int currentStride = 0;
559         do {
560             rnd = (rnd * 1664525 + 1013904223);
561             boolean sample = (rnd & rndMask) == 0;
562             if (sample) {
563                 time = System.nanoTime();
564             }
565             for (int b = 0; b < batchSize; b++) {
566                 if (control.volatileSpoiler) return;
567                 blackhole.consume(l_simplelrucachebenchmark0_G.testCacheRead());
568             }
569             if (sample) {
570                 buffer.add((System.nanoTime() - time) / opsPerInv);
571                 if (currentStride++ > targetSamples) {
572                     buffer.half();
573                     currentStride = 0;
574                     rndMask = (rndMask << 1) + 1;
575                 }
576             }
577             operations++;
578         } while(!control.isDone);
579         startRndMask = Math.max(startRndMask, rndMask);
580         result.realTime = realTime;
581         result.measuredOps = operations;
582     }
583 
584     public static void testCacheWrite_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, SimpleLruCacheBenchmark_jmhType l_simplelrucachebenchmark0_G) throws Throwable {
585         long realTime = 0;
586         long operations = 0;
587         int rnd = (int)System.nanoTime();
588         int rndMask = startRndMask;
589         long time = 0;
590         int currentStride = 0;
591         do {
592             rnd = (rnd * 1664525 + 1013904223);
593             boolean sample = (rnd & rndMask) == 0;
594             if (sample) {
595                 time = System.nanoTime();
596             }
597             for (int b = 0; b < batchSize; b++) {
598                 if (control.volatileSpoiler) return;
599                 blackhole.consume(l_simplelrucachebenchmark0_G.testCacheWrite());
600             }
601             if (sample) {
602                 buffer.add((System.nanoTime() - time) / opsPerInv);
603                 if (currentStride++ > targetSamples) {
604                     buffer.half();
605                     currentStride = 0;
606                     rndMask = (rndMask << 1) + 1;
607                 }
608             }
609             operations++;
610         } while(!control.isDone);
611         startRndMask = Math.max(startRndMask, rndMask);
612         result.realTime = realTime;
613         result.measuredOps = operations;
614     }
615 
616 
617     public BenchmarkTaskResult readwrite_SingleShotTime(InfraControl control, ThreadParams threadParams) throws Throwable {
618         this.benchmarkParams = control.benchmarkParams;
619         this.iterationParams = control.iterationParams;
620         this.threadParams    = threadParams;
621         this.notifyControl   = control.notifyControl;
622         if (this.blackhole == null) {
623             this.blackhole = new Blackhole("Today's password is swordfish. I understand instantiating Blackholes directly is dangerous.");
624         }
625         if (threadParams.getSubgroupIndex() == 0) {
626             SimpleLruCacheBenchmark_jmhType l_simplelrucachebenchmark0_G = _jmh_tryInit_f_simplelrucachebenchmark0_G(control);
627 
628             control.preSetup();
629 
630 
631             notifyControl.startMeasurement = true;
632             RawResults res = new RawResults();
633             int batchSize = iterationParams.getBatchSize();
634             testCacheRead_ss_jmhStub(control, res, benchmarkParams, iterationParams, threadParams, blackhole, notifyControl, startRndMask, batchSize, l_simplelrucachebenchmark0_G);
635             control.preTearDown();
636 
637             if (control.isLastIteration()) {
638                 if (SimpleLruCacheBenchmark_jmhType.tearTrialMutexUpdater.compareAndSet(l_simplelrucachebenchmark0_G, 0, 1)) {
639                     try {
640                         if (control.isFailing) throw new FailureAssistException();
641                         if (l_simplelrucachebenchmark0_G.readyTrial) {
642                             l_simplelrucachebenchmark0_G.teardown();
643                             l_simplelrucachebenchmark0_G.readyTrial = false;
644                         }
645                     } catch (Throwable t) {
646                         control.isFailing = true;
647                         throw t;
648                     } finally {
649                         SimpleLruCacheBenchmark_jmhType.tearTrialMutexUpdater.set(l_simplelrucachebenchmark0_G, 0);
650                     }
651                 } else {
652                     long l_simplelrucachebenchmark0_G_backoff = 1;
653                     while (SimpleLruCacheBenchmark_jmhType.tearTrialMutexUpdater.get(l_simplelrucachebenchmark0_G) == 1) {
654                         TimeUnit.MILLISECONDS.sleep(l_simplelrucachebenchmark0_G_backoff);
655                         l_simplelrucachebenchmark0_G_backoff = Math.max(1024, l_simplelrucachebenchmark0_G_backoff * 2);
656                         if (control.isFailing) throw new FailureAssistException();
657                         if (Thread.interrupted()) throw new InterruptedException();
658                     }
659                 }
660                 synchronized(this.getClass()) {
661                     f_simplelrucachebenchmark0_G = null;
662                 }
663             }
664             int opsPerInv = control.benchmarkParams.getOpsPerInvocation();
665             long totalOps = opsPerInv;
666             BenchmarkTaskResult results = new BenchmarkTaskResult(totalOps, totalOps);
667             results.add(new SingleShotResult(ResultRole.PRIMARY, "readwrite", res.getTime(), benchmarkParams.getTimeUnit()));
668             results.add(new SingleShotResult(ResultRole.SECONDARY, "testCacheRead", res.getTime(), benchmarkParams.getTimeUnit()));
669             this.blackhole.evaporate("Yes, I am Stephen Hawking, and know a thing or two about black holes.");
670             return results;
671         } else
672         if (threadParams.getSubgroupIndex() == 1) {
673             SimpleLruCacheBenchmark_jmhType l_simplelrucachebenchmark0_G = _jmh_tryInit_f_simplelrucachebenchmark0_G(control);
674 
675             control.preSetup();
676 
677 
678             notifyControl.startMeasurement = true;
679             RawResults res = new RawResults();
680             int batchSize = iterationParams.getBatchSize();
681             testCacheWrite_ss_jmhStub(control, res, benchmarkParams, iterationParams, threadParams, blackhole, notifyControl, startRndMask, batchSize, l_simplelrucachebenchmark0_G);
682             control.preTearDown();
683 
684             if (control.isLastIteration()) {
685                 if (SimpleLruCacheBenchmark_jmhType.tearTrialMutexUpdater.compareAndSet(l_simplelrucachebenchmark0_G, 0, 1)) {
686                     try {
687                         if (control.isFailing) throw new FailureAssistException();
688                         if (l_simplelrucachebenchmark0_G.readyTrial) {
689                             l_simplelrucachebenchmark0_G.teardown();
690                             l_simplelrucachebenchmark0_G.readyTrial = false;
691                         }
692                     } catch (Throwable t) {
693                         control.isFailing = true;
694                         throw t;
695                     } finally {
696                         SimpleLruCacheBenchmark_jmhType.tearTrialMutexUpdater.set(l_simplelrucachebenchmark0_G, 0);
697                     }
698                 } else {
699                     long l_simplelrucachebenchmark0_G_backoff = 1;
700                     while (SimpleLruCacheBenchmark_jmhType.tearTrialMutexUpdater.get(l_simplelrucachebenchmark0_G) == 1) {
701                         TimeUnit.MILLISECONDS.sleep(l_simplelrucachebenchmark0_G_backoff);
702                         l_simplelrucachebenchmark0_G_backoff = Math.max(1024, l_simplelrucachebenchmark0_G_backoff * 2);
703                         if (control.isFailing) throw new FailureAssistException();
704                         if (Thread.interrupted()) throw new InterruptedException();
705                     }
706                 }
707                 synchronized(this.getClass()) {
708                     f_simplelrucachebenchmark0_G = null;
709                 }
710             }
711             int opsPerInv = control.benchmarkParams.getOpsPerInvocation();
712             long totalOps = opsPerInv;
713             BenchmarkTaskResult results = new BenchmarkTaskResult(totalOps, totalOps);
714             results.add(new SingleShotResult(ResultRole.PRIMARY, "readwrite", res.getTime(), benchmarkParams.getTimeUnit()));
715             results.add(new SingleShotResult(ResultRole.SECONDARY, "testCacheWrite", res.getTime(), benchmarkParams.getTimeUnit()));
716             this.blackhole.evaporate("Yes, I am Stephen Hawking, and know a thing or two about black holes.");
717             return results;
718         } else
719             throw new IllegalStateException("Harness failed to distribute threads among groups properly");
720     }
721 
722     public static void testCacheRead_ss_jmhStub(InfraControl control, RawResults result, BenchmarkParams benchmarkParams, IterationParams iterationParams, ThreadParams threadParams, Blackhole blackhole, Control notifyControl, int startRndMask, int batchSize, SimpleLruCacheBenchmark_jmhType l_simplelrucachebenchmark0_G) throws Throwable {
723         long realTime = 0;
724         result.startTime = System.nanoTime();
725         for (int b = 0; b < batchSize; b++) {
726             if (control.volatileSpoiler) return;
727             blackhole.consume(l_simplelrucachebenchmark0_G.testCacheRead());
728         }
729         result.stopTime = System.nanoTime();
730         result.realTime = realTime;
731     }
732 
733     public static void testCacheWrite_ss_jmhStub(InfraControl control, RawResults result, BenchmarkParams benchmarkParams, IterationParams iterationParams, ThreadParams threadParams, Blackhole blackhole, Control notifyControl, int startRndMask, int batchSize, SimpleLruCacheBenchmark_jmhType l_simplelrucachebenchmark0_G) throws Throwable {
734         long realTime = 0;
735         result.startTime = System.nanoTime();
736         for (int b = 0; b < batchSize; b++) {
737             if (control.volatileSpoiler) return;
738             blackhole.consume(l_simplelrucachebenchmark0_G.testCacheWrite());
739         }
740         result.stopTime = System.nanoTime();
741         result.realTime = realTime;
742     }
743 
744     
745     static volatile SimpleLruCacheBenchmark_jmhType f_simplelrucachebenchmark0_G;
746     
747     SimpleLruCacheBenchmark_jmhType _jmh_tryInit_f_simplelrucachebenchmark0_G(InfraControl control) throws Throwable {
748         SimpleLruCacheBenchmark_jmhType val = f_simplelrucachebenchmark0_G;
749         if (val != null) {
750             return val;
751         }
752         synchronized(this.getClass()) {
753             try {
754             if (control.isFailing) throw new FailureAssistException();
755             val = f_simplelrucachebenchmark0_G;
756             if (val != null) {
757                 return val;
758             }
759             val = new SimpleLruCacheBenchmark_jmhType();
760             val.setupBenchmark();
761             val.readyTrial = true;
762             f_simplelrucachebenchmark0_G = val;
763             } catch (Throwable t) {
764                 control.isFailing = true;
765                 throw t;
766             }
767         }
768         return val;
769     }
770 
771 
772 }
773