You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

214 lines
11 KiB

2 months ago
  1. #include "benchmark/benchmark.h"
  2. #include "output_test.h"
  3. // ========================================================================= //
  4. // ------------------------ Testing Basic Output --------------------------- //
  5. // ========================================================================= //
  6. static void BM_ExplicitRepetitions(benchmark::State& state) {
  7. for (auto _ : state) {
  8. }
  9. }
  10. BENCHMARK(BM_ExplicitRepetitions)->Repetitions(2);
  11. ADD_CASES(TC_ConsoleOut,
  12. {{"^BM_ExplicitRepetitions/repeats:2 %console_report$"}});
  13. ADD_CASES(TC_ConsoleOut,
  14. {{"^BM_ExplicitRepetitions/repeats:2 %console_report$"}});
  15. ADD_CASES(TC_ConsoleOut,
  16. {{"^BM_ExplicitRepetitions/repeats:2_mean %console_report$"}});
  17. ADD_CASES(TC_ConsoleOut,
  18. {{"^BM_ExplicitRepetitions/repeats:2_median %console_report$"}});
  19. ADD_CASES(TC_ConsoleOut,
  20. {{"^BM_ExplicitRepetitions/repeats:2_stddev %console_report$"}});
  21. ADD_CASES(TC_JSONOut,
  22. {{"\"name\": \"BM_ExplicitRepetitions/repeats:2\",$"},
  23. {"\"family_index\": 0,$", MR_Next},
  24. {"\"per_family_instance_index\": 0,$", MR_Next},
  25. {"\"run_name\": \"BM_ExplicitRepetitions/repeats:2\",$", MR_Next},
  26. {"\"run_type\": \"iteration\",$", MR_Next},
  27. {"\"repetitions\": 2,$", MR_Next},
  28. {"\"repetition_index\": 0,$", MR_Next},
  29. {"\"threads\": 1,$", MR_Next},
  30. {"\"iterations\": %int,$", MR_Next},
  31. {"\"real_time\": %float,$", MR_Next},
  32. {"\"cpu_time\": %float,$", MR_Next},
  33. {"\"time_unit\": \"ns\"$", MR_Next},
  34. {"}", MR_Next}});
  35. ADD_CASES(TC_JSONOut,
  36. {{"\"name\": \"BM_ExplicitRepetitions/repeats:2\",$"},
  37. {"\"family_index\": 0,$", MR_Next},
  38. {"\"per_family_instance_index\": 0,$", MR_Next},
  39. {"\"run_name\": \"BM_ExplicitRepetitions/repeats:2\",$", MR_Next},
  40. {"\"run_type\": \"iteration\",$", MR_Next},
  41. {"\"repetitions\": 2,$", MR_Next},
  42. {"\"repetition_index\": 1,$", MR_Next},
  43. {"\"threads\": 1,$", MR_Next},
  44. {"\"iterations\": %int,$", MR_Next},
  45. {"\"real_time\": %float,$", MR_Next},
  46. {"\"cpu_time\": %float,$", MR_Next},
  47. {"\"time_unit\": \"ns\"$", MR_Next},
  48. {"}", MR_Next}});
  49. ADD_CASES(TC_JSONOut,
  50. {{"\"name\": \"BM_ExplicitRepetitions/repeats:2_mean\",$"},
  51. {"\"family_index\": 0,$", MR_Next},
  52. {"\"per_family_instance_index\": 0,$", MR_Next},
  53. {"\"run_name\": \"BM_ExplicitRepetitions/repeats:2\",$", MR_Next},
  54. {"\"run_type\": \"aggregate\",$", MR_Next},
  55. {"\"repetitions\": 2,$", MR_Next},
  56. {"\"threads\": 1,$", MR_Next},
  57. {"\"aggregate_name\": \"mean\",$", MR_Next},
  58. {"\"aggregate_unit\": \"time\",$", MR_Next},
  59. {"\"iterations\": %int,$", MR_Next},
  60. {"\"real_time\": %float,$", MR_Next},
  61. {"\"cpu_time\": %float,$", MR_Next},
  62. {"\"time_unit\": \"ns\"$", MR_Next},
  63. {"}", MR_Next}});
  64. ADD_CASES(TC_JSONOut,
  65. {{"\"name\": \"BM_ExplicitRepetitions/repeats:2_median\",$"},
  66. {"\"family_index\": 0,$", MR_Next},
  67. {"\"per_family_instance_index\": 0,$", MR_Next},
  68. {"\"run_name\": \"BM_ExplicitRepetitions/repeats:2\",$", MR_Next},
  69. {"\"run_type\": \"aggregate\",$", MR_Next},
  70. {"\"repetitions\": 2,$", MR_Next},
  71. {"\"threads\": 1,$", MR_Next},
  72. {"\"aggregate_name\": \"median\",$", MR_Next},
  73. {"\"aggregate_unit\": \"time\",$", MR_Next},
  74. {"\"iterations\": %int,$", MR_Next},
  75. {"\"real_time\": %float,$", MR_Next},
  76. {"\"cpu_time\": %float,$", MR_Next},
  77. {"\"time_unit\": \"ns\"$", MR_Next},
  78. {"}", MR_Next}});
  79. ADD_CASES(TC_JSONOut,
  80. {{"\"name\": \"BM_ExplicitRepetitions/repeats:2_stddev\",$"},
  81. {"\"family_index\": 0,$", MR_Next},
  82. {"\"per_family_instance_index\": 0,$", MR_Next},
  83. {"\"run_name\": \"BM_ExplicitRepetitions/repeats:2\",$", MR_Next},
  84. {"\"run_type\": \"aggregate\",$", MR_Next},
  85. {"\"repetitions\": 2,$", MR_Next},
  86. {"\"threads\": 1,$", MR_Next},
  87. {"\"aggregate_name\": \"stddev\",$", MR_Next},
  88. {"\"aggregate_unit\": \"time\",$", MR_Next},
  89. {"\"iterations\": %int,$", MR_Next},
  90. {"\"real_time\": %float,$", MR_Next},
  91. {"\"cpu_time\": %float,$", MR_Next},
  92. {"\"time_unit\": \"ns\"$", MR_Next},
  93. {"}", MR_Next}});
  94. ADD_CASES(TC_CSVOut, {{"^\"BM_ExplicitRepetitions/repeats:2\",%csv_report$"}});
  95. ADD_CASES(TC_CSVOut, {{"^\"BM_ExplicitRepetitions/repeats:2\",%csv_report$"}});
  96. ADD_CASES(TC_CSVOut,
  97. {{"^\"BM_ExplicitRepetitions/repeats:2_mean\",%csv_report$"}});
  98. ADD_CASES(TC_CSVOut,
  99. {{"^\"BM_ExplicitRepetitions/repeats:2_median\",%csv_report$"}});
  100. ADD_CASES(TC_CSVOut,
  101. {{"^\"BM_ExplicitRepetitions/repeats:2_stddev\",%csv_report$"}});
  102. // ========================================================================= //
  103. // ------------------------ Testing Basic Output --------------------------- //
  104. // ========================================================================= //
  105. static void BM_ImplicitRepetitions(benchmark::State& state) {
  106. for (auto _ : state) {
  107. }
  108. }
  109. BENCHMARK(BM_ImplicitRepetitions);
  110. ADD_CASES(TC_ConsoleOut, {{"^BM_ImplicitRepetitions %console_report$"}});
  111. ADD_CASES(TC_ConsoleOut, {{"^BM_ImplicitRepetitions %console_report$"}});
  112. ADD_CASES(TC_ConsoleOut, {{"^BM_ImplicitRepetitions %console_report$"}});
  113. ADD_CASES(TC_ConsoleOut, {{"^BM_ImplicitRepetitions_mean %console_report$"}});
  114. ADD_CASES(TC_ConsoleOut, {{"^BM_ImplicitRepetitions_median %console_report$"}});
  115. ADD_CASES(TC_ConsoleOut, {{"^BM_ImplicitRepetitions_stddev %console_report$"}});
  116. ADD_CASES(TC_JSONOut, {{"\"name\": \"BM_ImplicitRepetitions\",$"},
  117. {"\"family_index\": 1,$", MR_Next},
  118. {"\"per_family_instance_index\": 0,$", MR_Next},
  119. {"\"run_name\": \"BM_ImplicitRepetitions\",$", MR_Next},
  120. {"\"run_type\": \"iteration\",$", MR_Next},
  121. {"\"repetitions\": 3,$", MR_Next},
  122. {"\"repetition_index\": 0,$", MR_Next},
  123. {"\"threads\": 1,$", MR_Next},
  124. {"\"iterations\": %int,$", MR_Next},
  125. {"\"real_time\": %float,$", MR_Next},
  126. {"\"cpu_time\": %float,$", MR_Next},
  127. {"\"time_unit\": \"ns\"$", MR_Next},
  128. {"}", MR_Next}});
  129. ADD_CASES(TC_JSONOut, {{"\"name\": \"BM_ImplicitRepetitions\",$"},
  130. {"\"family_index\": 1,$", MR_Next},
  131. {"\"per_family_instance_index\": 0,$", MR_Next},
  132. {"\"run_name\": \"BM_ImplicitRepetitions\",$", MR_Next},
  133. {"\"run_type\": \"iteration\",$", MR_Next},
  134. {"\"repetitions\": 3,$", MR_Next},
  135. {"\"repetition_index\": 1,$", MR_Next},
  136. {"\"threads\": 1,$", MR_Next},
  137. {"\"iterations\": %int,$", MR_Next},
  138. {"\"real_time\": %float,$", MR_Next},
  139. {"\"cpu_time\": %float,$", MR_Next},
  140. {"\"time_unit\": \"ns\"$", MR_Next},
  141. {"}", MR_Next}});
  142. ADD_CASES(TC_JSONOut, {{"\"name\": \"BM_ImplicitRepetitions\",$"},
  143. {"\"family_index\": 1,$", MR_Next},
  144. {"\"per_family_instance_index\": 0,$", MR_Next},
  145. {"\"run_name\": \"BM_ImplicitRepetitions\",$", MR_Next},
  146. {"\"run_type\": \"iteration\",$", MR_Next},
  147. {"\"repetitions\": 3,$", MR_Next},
  148. {"\"repetition_index\": 2,$", MR_Next},
  149. {"\"threads\": 1,$", MR_Next},
  150. {"\"iterations\": %int,$", MR_Next},
  151. {"\"real_time\": %float,$", MR_Next},
  152. {"\"cpu_time\": %float,$", MR_Next},
  153. {"\"time_unit\": \"ns\"$", MR_Next},
  154. {"}", MR_Next}});
  155. ADD_CASES(TC_JSONOut, {{"\"name\": \"BM_ImplicitRepetitions_mean\",$"},
  156. {"\"family_index\": 1,$", MR_Next},
  157. {"\"per_family_instance_index\": 0,$", MR_Next},
  158. {"\"run_name\": \"BM_ImplicitRepetitions\",$", MR_Next},
  159. {"\"run_type\": \"aggregate\",$", MR_Next},
  160. {"\"repetitions\": 3,$", MR_Next},
  161. {"\"threads\": 1,$", MR_Next},
  162. {"\"aggregate_name\": \"mean\",$", MR_Next},
  163. {"\"aggregate_unit\": \"time\",$", MR_Next},
  164. {"\"iterations\": %int,$", MR_Next},
  165. {"\"real_time\": %float,$", MR_Next},
  166. {"\"cpu_time\": %float,$", MR_Next},
  167. {"\"time_unit\": \"ns\"$", MR_Next},
  168. {"}", MR_Next}});
  169. ADD_CASES(TC_JSONOut, {{"\"name\": \"BM_ImplicitRepetitions_median\",$"},
  170. {"\"family_index\": 1,$", MR_Next},
  171. {"\"per_family_instance_index\": 0,$", MR_Next},
  172. {"\"run_name\": \"BM_ImplicitRepetitions\",$", MR_Next},
  173. {"\"run_type\": \"aggregate\",$", MR_Next},
  174. {"\"repetitions\": 3,$", MR_Next},
  175. {"\"threads\": 1,$", MR_Next},
  176. {"\"aggregate_name\": \"median\",$", MR_Next},
  177. {"\"aggregate_unit\": \"time\",$", MR_Next},
  178. {"\"iterations\": %int,$", MR_Next},
  179. {"\"real_time\": %float,$", MR_Next},
  180. {"\"cpu_time\": %float,$", MR_Next},
  181. {"\"time_unit\": \"ns\"$", MR_Next},
  182. {"}", MR_Next}});
  183. ADD_CASES(TC_JSONOut, {{"\"name\": \"BM_ImplicitRepetitions_stddev\",$"},
  184. {"\"family_index\": 1,$", MR_Next},
  185. {"\"per_family_instance_index\": 0,$", MR_Next},
  186. {"\"run_name\": \"BM_ImplicitRepetitions\",$", MR_Next},
  187. {"\"run_type\": \"aggregate\",$", MR_Next},
  188. {"\"repetitions\": 3,$", MR_Next},
  189. {"\"threads\": 1,$", MR_Next},
  190. {"\"aggregate_name\": \"stddev\",$", MR_Next},
  191. {"\"aggregate_unit\": \"time\",$", MR_Next},
  192. {"\"iterations\": %int,$", MR_Next},
  193. {"\"real_time\": %float,$", MR_Next},
  194. {"\"cpu_time\": %float,$", MR_Next},
  195. {"\"time_unit\": \"ns\"$", MR_Next},
  196. {"}", MR_Next}});
  197. ADD_CASES(TC_CSVOut, {{"^\"BM_ImplicitRepetitions\",%csv_report$"}});
  198. ADD_CASES(TC_CSVOut, {{"^\"BM_ImplicitRepetitions\",%csv_report$"}});
  199. ADD_CASES(TC_CSVOut, {{"^\"BM_ImplicitRepetitions_mean\",%csv_report$"}});
  200. ADD_CASES(TC_CSVOut, {{"^\"BM_ImplicitRepetitions_median\",%csv_report$"}});
  201. ADD_CASES(TC_CSVOut, {{"^\"BM_ImplicitRepetitions_stddev\",%csv_report$"}});
  202. // ========================================================================= //
  203. // --------------------------- TEST CASES END ------------------------------ //
  204. // ========================================================================= //
  205. int main(int argc, char* argv[]) { RunOutputTests(argc, argv); }