MyBenchmark_testMethod.java 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282
  1. package org.sample.generated;
  2. import java.util.List;
  3. import java.util.concurrent.atomic.AtomicInteger;
  4. import java.util.Collection;
  5. import java.util.ArrayList;
  6. import java.util.concurrent.TimeUnit;
  7. import javax.annotation.Generated;
  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.Result;
  12. import org.openjdk.jmh.results.ThroughputResult;
  13. import org.openjdk.jmh.results.AverageTimeResult;
  14. import org.openjdk.jmh.results.SampleTimeResult;
  15. import org.openjdk.jmh.results.SingleShotResult;
  16. import org.openjdk.jmh.util.SampleBuffer;
  17. import org.openjdk.jmh.annotations.Mode;
  18. import org.openjdk.jmh.annotations.Fork;
  19. import org.openjdk.jmh.annotations.Measurement;
  20. import org.openjdk.jmh.annotations.Threads;
  21. import org.openjdk.jmh.annotations.Warmup;
  22. import org.openjdk.jmh.annotations.BenchmarkMode;
  23. import org.openjdk.jmh.results.RawResults;
  24. import org.openjdk.jmh.results.ResultRole;
  25. import java.lang.reflect.Field;
  26. import org.openjdk.jmh.infra.BenchmarkParams;
  27. import org.openjdk.jmh.infra.IterationParams;
  28. import org.openjdk.jmh.infra.generated.Blackhole_jmh;
  29. import org.sample.generated.MyBenchmark_jmh;
  30. @Generated("org.openjdk.jmh.generators.core.BenchmarkGenerator")
  31. public final class MyBenchmark_testMethod {
  32. boolean p000, p001, p002, p003, p004, p005, p006, p007, p008, p009, p010, p011, p012, p013, p014, p015;
  33. boolean p016, p017, p018, p019, p020, p021, p022, p023, p024, p025, p026, p027, p028, p029, p030, p031;
  34. boolean p032, p033, p034, p035, p036, p037, p038, p039, p040, p041, p042, p043, p044, p045, p046, p047;
  35. boolean p048, p049, p050, p051, p052, p053, p054, p055, p056, p057, p058, p059, p060, p061, p062, p063;
  36. boolean p064, p065, p066, p067, p068, p069, p070, p071, p072, p073, p074, p075, p076, p077, p078, p079;
  37. boolean p080, p081, p082, p083, p084, p085, p086, p087, p088, p089, p090, p091, p092, p093, p094, p095;
  38. boolean p096, p097, p098, p099, p100, p101, p102, p103, p104, p105, p106, p107, p108, p109, p110, p111;
  39. boolean p112, p113, p114, p115, p116, p117, p118, p119, p120, p121, p122, p123, p124, p125, p126, p127;
  40. boolean p128, p129, p130, p131, p132, p133, p134, p135, p136, p137, p138, p139, p140, p141, p142, p143;
  41. boolean p144, p145, p146, p147, p148, p149, p150, p151, p152, p153, p154, p155, p156, p157, p158, p159;
  42. boolean p160, p161, p162, p163, p164, p165, p166, p167, p168, p169, p170, p171, p172, p173, p174, p175;
  43. boolean p176, p177, p178, p179, p180, p181, p182, p183, p184, p185, p186, p187, p188, p189, p190, p191;
  44. boolean p192, p193, p194, p195, p196, p197, p198, p199, p200, p201, p202, p203, p204, p205, p206, p207;
  45. boolean p208, p209, p210, p211, p212, p213, p214, p215, p216, p217, p218, p219, p220, p221, p222, p223;
  46. boolean p224, p225, p226, p227, p228, p229, p230, p231, p232, p233, p234, p235, p236, p237, p238, p239;
  47. boolean p240, p241, p242, p243, p244, p245, p246, p247, p248, p249, p250, p251, p252, p253, p254, p255;
  48. int startRndMask;
  49. public Collection<ThroughputResult> testMethod_Throughput(InfraControl control, ThreadParams threadParams) throws Throwable {
  50. if (threadParams.getSubgroupIndex() == 0) {
  51. Blackhole_jmh l_blackhole1_1 = _jmh_tryInit_f_blackhole1_1(control, threadParams);
  52. MyBenchmark_jmh l_mybenchmark0_0 = _jmh_tryInit_f_mybenchmark0_0(control, threadParams);
  53. control.preSetup();
  54. l_blackhole1_1.clearSinks();
  55. control.announceWarmupReady();
  56. while (control.warmupShouldWait) {
  57. l_mybenchmark0_0.testMethod();
  58. }
  59. RawResults res = new RawResults(control.benchmarkParams.getOpsPerInvocation());
  60. testMethod_thrpt_jmhStub(control, res, l_mybenchmark0_0, l_blackhole1_1);
  61. res.operations /= control.iterationParams.getBatchSize();
  62. control.announceWarmdownReady();
  63. try {
  64. while (control.warmdownShouldWait) {
  65. l_mybenchmark0_0.testMethod();
  66. }
  67. control.preTearDown();
  68. } catch (InterruptedException ie) {
  69. control.preTearDownForce();
  70. }
  71. if (control.isLastIteration()) {
  72. f_mybenchmark0_0 = null;
  73. f_blackhole1_1 = null;
  74. }
  75. Collection<ThroughputResult> results = new ArrayList<ThroughputResult>();
  76. results.add(new ThroughputResult(ResultRole.PRIMARY, "testMethod", res.getOperations(), res.getTime(), control.benchmarkParams.getTimeUnit()));
  77. return results;
  78. } else
  79. throw new IllegalStateException("Harness failed to distribute threads among groups properly");
  80. }
  81. public void testMethod_thrpt_jmhStub(InfraControl control, RawResults result, MyBenchmark_jmh l_mybenchmark0_0, Blackhole_jmh l_blackhole1_1) throws Throwable {
  82. long operations = 0;
  83. long realTime = 0;
  84. result.startTime = System.nanoTime();
  85. do {
  86. l_mybenchmark0_0.testMethod();
  87. operations++;
  88. } while(!control.isDone);
  89. result.stopTime = System.nanoTime();
  90. result.realTime = realTime;
  91. result.operations = operations;
  92. }
  93. public Collection<AverageTimeResult> testMethod_AverageTime(InfraControl control, ThreadParams threadParams) throws Throwable {
  94. if (threadParams.getSubgroupIndex() == 0) {
  95. Blackhole_jmh l_blackhole1_1 = _jmh_tryInit_f_blackhole1_1(control, threadParams);
  96. MyBenchmark_jmh l_mybenchmark0_0 = _jmh_tryInit_f_mybenchmark0_0(control, threadParams);
  97. control.preSetup();
  98. l_blackhole1_1.clearSinks();
  99. control.announceWarmupReady();
  100. while (control.warmupShouldWait) {
  101. l_mybenchmark0_0.testMethod();
  102. }
  103. RawResults res = new RawResults(control.benchmarkParams.getOpsPerInvocation());
  104. testMethod_avgt_jmhStub(control, res, l_mybenchmark0_0, l_blackhole1_1);
  105. res.operations /= control.iterationParams.getBatchSize();
  106. control.announceWarmdownReady();
  107. try {
  108. while (control.warmdownShouldWait) {
  109. l_mybenchmark0_0.testMethod();
  110. }
  111. control.preTearDown();
  112. } catch (InterruptedException ie) {
  113. control.preTearDownForce();
  114. }
  115. if (control.isLastIteration()) {
  116. f_mybenchmark0_0 = null;
  117. f_blackhole1_1 = null;
  118. }
  119. Collection<AverageTimeResult> results = new ArrayList<AverageTimeResult>();
  120. results.add(new AverageTimeResult(ResultRole.PRIMARY, "testMethod", res.getOperations(), res.getTime(), control.benchmarkParams.getTimeUnit()));
  121. return results;
  122. } else
  123. throw new IllegalStateException("Harness failed to distribute threads among groups properly");
  124. }
  125. public void testMethod_avgt_jmhStub(InfraControl control, RawResults result, MyBenchmark_jmh l_mybenchmark0_0, Blackhole_jmh l_blackhole1_1) throws Throwable {
  126. long operations = 0;
  127. long realTime = 0;
  128. result.startTime = System.nanoTime();
  129. do {
  130. l_mybenchmark0_0.testMethod();
  131. operations++;
  132. } while(!control.isDone);
  133. result.stopTime = System.nanoTime();
  134. result.realTime = realTime;
  135. result.operations = operations;
  136. }
  137. public Collection<SampleTimeResult> testMethod_SampleTime(InfraControl control, ThreadParams threadParams) throws Throwable {
  138. if (threadParams.getSubgroupIndex() == 0) {
  139. Blackhole_jmh l_blackhole1_1 = _jmh_tryInit_f_blackhole1_1(control, threadParams);
  140. MyBenchmark_jmh l_mybenchmark0_0 = _jmh_tryInit_f_mybenchmark0_0(control, threadParams);
  141. control.preSetup();
  142. l_blackhole1_1.clearSinks();
  143. control.announceWarmupReady();
  144. while (control.warmupShouldWait) {
  145. l_mybenchmark0_0.testMethod();
  146. }
  147. int targetSamples = (int) (control.getDuration(TimeUnit.MILLISECONDS) * 20); // at max, 20 timestamps per millisecond
  148. int batchSize = control.iterationParams.getBatchSize();
  149. SampleBuffer buffer = new SampleBuffer();
  150. testMethod_sample_jmhStub(control, buffer, targetSamples, control.benchmarkParams.getOpsPerInvocation(), batchSize, l_mybenchmark0_0, l_blackhole1_1);
  151. control.announceWarmdownReady();
  152. try {
  153. while (control.warmdownShouldWait) {
  154. l_mybenchmark0_0.testMethod();
  155. }
  156. control.preTearDown();
  157. } catch (InterruptedException ie) {
  158. control.preTearDownForce();
  159. }
  160. if (control.isLastIteration()) {
  161. f_mybenchmark0_0 = null;
  162. f_blackhole1_1 = null;
  163. }
  164. Collection<SampleTimeResult> results = new ArrayList<SampleTimeResult>();
  165. results.add(new SampleTimeResult(ResultRole.PRIMARY, "testMethod", buffer, control.benchmarkParams.getTimeUnit()));
  166. return results;
  167. } else
  168. throw new IllegalStateException("Harness failed to distribute threads among groups properly");
  169. }
  170. public void testMethod_sample_jmhStub(InfraControl control, SampleBuffer buffer, int targetSamples, long opsPerInv, int batchSize, MyBenchmark_jmh l_mybenchmark0_0, Blackhole_jmh l_blackhole1_1) throws Throwable {
  171. long realTime = 0;
  172. int rnd = (int)System.nanoTime();
  173. int rndMask = startRndMask;
  174. long time = 0;
  175. int currentStride = 0;
  176. do {
  177. rnd = (rnd * 1664525 + 1013904223);
  178. boolean sample = (rnd & rndMask) == 0;
  179. if (sample) {
  180. time = System.nanoTime();
  181. }
  182. for (int b = 0; b < batchSize; b++) {
  183. if (control.volatileSpoiler) return;
  184. l_mybenchmark0_0.testMethod();
  185. }
  186. if (sample) {
  187. buffer.add((System.nanoTime() - time) / opsPerInv);
  188. if (currentStride++ > targetSamples) {
  189. buffer.half();
  190. currentStride = 0;
  191. rndMask = (rndMask << 1) + 1;
  192. }
  193. }
  194. } while(!control.isDone);
  195. startRndMask = Math.max(startRndMask, rndMask);
  196. }
  197. public Collection<SingleShotResult> testMethod_SingleShotTime(InfraControl control, ThreadParams threadParams) throws Throwable {
  198. if (threadParams.getSubgroupIndex() == 0) {
  199. Blackhole_jmh l_blackhole1_1 = _jmh_tryInit_f_blackhole1_1(control, threadParams);
  200. MyBenchmark_jmh l_mybenchmark0_0 = _jmh_tryInit_f_mybenchmark0_0(control, threadParams);
  201. control.preSetup();
  202. l_blackhole1_1.clearSinks();
  203. RawResults res = new RawResults(control.benchmarkParams.getOpsPerInvocation());
  204. int batchSize = control.iterationParams.getBatchSize();
  205. testMethod_ss_jmhStub(control, batchSize, res, l_mybenchmark0_0, l_blackhole1_1);
  206. control.preTearDown();
  207. if (control.isLastIteration()) {
  208. f_mybenchmark0_0 = null;
  209. f_blackhole1_1 = null;
  210. }
  211. Collection<SingleShotResult> results = new ArrayList<SingleShotResult>();
  212. results.add(new SingleShotResult(ResultRole.PRIMARY, "testMethod", res.getTime(), control.benchmarkParams.getTimeUnit()));
  213. return results;
  214. } else
  215. throw new IllegalStateException("Harness failed to distribute threads among groups properly");
  216. }
  217. public void testMethod_ss_jmhStub(InfraControl control, int batchSize, RawResults result, MyBenchmark_jmh l_mybenchmark0_0, Blackhole_jmh l_blackhole1_1) throws Throwable {
  218. long realTime = 0;
  219. result.startTime = System.nanoTime();
  220. for (int b = 0; b < batchSize; b++) {
  221. if (control.volatileSpoiler) return;
  222. l_mybenchmark0_0.testMethod();
  223. }
  224. result.stopTime = System.nanoTime();
  225. result.realTime = realTime;
  226. }
  227. Blackhole_jmh f_blackhole1_1;
  228. Blackhole_jmh _jmh_tryInit_f_blackhole1_1(InfraControl control, ThreadParams threadParams) throws Throwable {
  229. Blackhole_jmh val = f_blackhole1_1;
  230. if (val == null) {
  231. val = new Blackhole_jmh();
  232. f_blackhole1_1 = val;
  233. }
  234. return val;
  235. }
  236. MyBenchmark_jmh f_mybenchmark0_0;
  237. MyBenchmark_jmh _jmh_tryInit_f_mybenchmark0_0(InfraControl control, ThreadParams threadParams) throws Throwable {
  238. MyBenchmark_jmh val = f_mybenchmark0_0;
  239. if (val == null) {
  240. val = new MyBenchmark_jmh();
  241. f_mybenchmark0_0 = val;
  242. }
  243. return val;
  244. }
  245. }