1a8c51b3fSopenharmony_ci 2a8c51b3fSopenharmony_ci#undef NDEBUG 3a8c51b3fSopenharmony_ci#include <numeric> 4a8c51b3fSopenharmony_ci#include <utility> 5a8c51b3fSopenharmony_ci 6a8c51b3fSopenharmony_ci#include "benchmark/benchmark.h" 7a8c51b3fSopenharmony_ci#include "output_test.h" 8a8c51b3fSopenharmony_ci 9a8c51b3fSopenharmony_ci// ========================================================================= // 10a8c51b3fSopenharmony_ci// ---------------------- Testing Prologue Output -------------------------- // 11a8c51b3fSopenharmony_ci// ========================================================================= // 12a8c51b3fSopenharmony_ci 13a8c51b3fSopenharmony_ciADD_CASES(TC_ConsoleOut, {{"^[-]+$", MR_Next}, 14a8c51b3fSopenharmony_ci {"^Benchmark %s Time %s CPU %s Iterations$", MR_Next}, 15a8c51b3fSopenharmony_ci {"^[-]+$", MR_Next}}); 16a8c51b3fSopenharmony_cistatic int AddContextCases() { 17a8c51b3fSopenharmony_ci AddCases(TC_ConsoleErr, 18a8c51b3fSopenharmony_ci { 19a8c51b3fSopenharmony_ci {"^%int-%int-%intT%int:%int:%int[-+]%int:%int$", MR_Default}, 20a8c51b3fSopenharmony_ci {"Running .*(/|\\\\)reporter_output_test(\\.exe)?$", MR_Next}, 21a8c51b3fSopenharmony_ci {"Run on \\(%int X %float MHz CPU s?\\)", MR_Next}, 22a8c51b3fSopenharmony_ci }); 23a8c51b3fSopenharmony_ci AddCases(TC_JSONOut, 24a8c51b3fSopenharmony_ci {{"^\\{", MR_Default}, 25a8c51b3fSopenharmony_ci {"\"context\":", MR_Next}, 26a8c51b3fSopenharmony_ci {"\"date\": \"", MR_Next}, 27a8c51b3fSopenharmony_ci {"\"host_name\":", MR_Next}, 28a8c51b3fSopenharmony_ci {"\"executable\": \".*(/|\\\\)reporter_output_test(\\.exe)?\",", 29a8c51b3fSopenharmony_ci MR_Next}, 30a8c51b3fSopenharmony_ci {"\"num_cpus\": %int,$", MR_Next}, 31a8c51b3fSopenharmony_ci {"\"mhz_per_cpu\": %float,$", MR_Next}, 32a8c51b3fSopenharmony_ci {"\"caches\": \\[$", MR_Default}}); 33a8c51b3fSopenharmony_ci auto const& Info = benchmark::CPUInfo::Get(); 34a8c51b3fSopenharmony_ci auto const& Caches = Info.caches; 35a8c51b3fSopenharmony_ci if (!Caches.empty()) { 36a8c51b3fSopenharmony_ci AddCases(TC_ConsoleErr, {{"CPU Caches:$", MR_Next}}); 37a8c51b3fSopenharmony_ci } 38a8c51b3fSopenharmony_ci for (size_t I = 0; I < Caches.size(); ++I) { 39a8c51b3fSopenharmony_ci std::string num_caches_str = 40a8c51b3fSopenharmony_ci Caches[I].num_sharing != 0 ? " \\(x%int\\)$" : "$"; 41a8c51b3fSopenharmony_ci AddCases(TC_ConsoleErr, 42a8c51b3fSopenharmony_ci {{"L%int (Data|Instruction|Unified) %int KiB" + num_caches_str, 43a8c51b3fSopenharmony_ci MR_Next}}); 44a8c51b3fSopenharmony_ci AddCases(TC_JSONOut, {{"\\{$", MR_Next}, 45a8c51b3fSopenharmony_ci {"\"type\": \"", MR_Next}, 46a8c51b3fSopenharmony_ci {"\"level\": %int,$", MR_Next}, 47a8c51b3fSopenharmony_ci {"\"size\": %int,$", MR_Next}, 48a8c51b3fSopenharmony_ci {"\"num_sharing\": %int$", MR_Next}, 49a8c51b3fSopenharmony_ci {"}[,]{0,1}$", MR_Next}}); 50a8c51b3fSopenharmony_ci } 51a8c51b3fSopenharmony_ci AddCases(TC_JSONOut, {{"],$"}}); 52a8c51b3fSopenharmony_ci auto const& LoadAvg = Info.load_avg; 53a8c51b3fSopenharmony_ci if (!LoadAvg.empty()) { 54a8c51b3fSopenharmony_ci AddCases(TC_ConsoleErr, 55a8c51b3fSopenharmony_ci {{"Load Average: (%float, ){0,2}%float$", MR_Next}}); 56a8c51b3fSopenharmony_ci } 57a8c51b3fSopenharmony_ci AddCases(TC_JSONOut, {{"\"load_avg\": \\[(%float,?){0,3}],$", MR_Next}}); 58a8c51b3fSopenharmony_ci return 0; 59a8c51b3fSopenharmony_ci} 60a8c51b3fSopenharmony_ciint dummy_register = AddContextCases(); 61a8c51b3fSopenharmony_ciADD_CASES(TC_CSVOut, {{"%csv_header"}}); 62a8c51b3fSopenharmony_ci 63a8c51b3fSopenharmony_ci// ========================================================================= // 64a8c51b3fSopenharmony_ci// ------------------------ Testing Basic Output --------------------------- // 65a8c51b3fSopenharmony_ci// ========================================================================= // 66a8c51b3fSopenharmony_ci 67a8c51b3fSopenharmony_civoid BM_basic(benchmark::State& state) { 68a8c51b3fSopenharmony_ci for (auto _ : state) { 69a8c51b3fSopenharmony_ci } 70a8c51b3fSopenharmony_ci} 71a8c51b3fSopenharmony_ciBENCHMARK(BM_basic); 72a8c51b3fSopenharmony_ci 73a8c51b3fSopenharmony_ciADD_CASES(TC_ConsoleOut, {{"^BM_basic %console_report$"}}); 74a8c51b3fSopenharmony_ciADD_CASES(TC_JSONOut, {{"\"name\": \"BM_basic\",$"}, 75a8c51b3fSopenharmony_ci {"\"family_index\": 0,$", MR_Next}, 76a8c51b3fSopenharmony_ci {"\"per_family_instance_index\": 0,$", MR_Next}, 77a8c51b3fSopenharmony_ci {"\"run_name\": \"BM_basic\",$", MR_Next}, 78a8c51b3fSopenharmony_ci {"\"run_type\": \"iteration\",$", MR_Next}, 79a8c51b3fSopenharmony_ci {"\"repetitions\": 1,$", MR_Next}, 80a8c51b3fSopenharmony_ci {"\"repetition_index\": 0,$", MR_Next}, 81a8c51b3fSopenharmony_ci {"\"threads\": 1,$", MR_Next}, 82a8c51b3fSopenharmony_ci {"\"iterations\": %int,$", MR_Next}, 83a8c51b3fSopenharmony_ci {"\"real_time\": %float,$", MR_Next}, 84a8c51b3fSopenharmony_ci {"\"cpu_time\": %float,$", MR_Next}, 85a8c51b3fSopenharmony_ci {"\"time_unit\": \"ns\"$", MR_Next}, 86a8c51b3fSopenharmony_ci {"}", MR_Next}}); 87a8c51b3fSopenharmony_ciADD_CASES(TC_CSVOut, {{"^\"BM_basic\",%csv_report$"}}); 88a8c51b3fSopenharmony_ci 89a8c51b3fSopenharmony_ci// ========================================================================= // 90a8c51b3fSopenharmony_ci// ------------------------ Testing Bytes per Second Output ---------------- // 91a8c51b3fSopenharmony_ci// ========================================================================= // 92a8c51b3fSopenharmony_ci 93a8c51b3fSopenharmony_civoid BM_bytes_per_second(benchmark::State& state) { 94a8c51b3fSopenharmony_ci for (auto _ : state) { 95a8c51b3fSopenharmony_ci // This test requires a non-zero CPU time to avoid divide-by-zero 96a8c51b3fSopenharmony_ci auto iterations = state.iterations(); 97a8c51b3fSopenharmony_ci benchmark::DoNotOptimize(iterations); 98a8c51b3fSopenharmony_ci } 99a8c51b3fSopenharmony_ci state.SetBytesProcessed(1); 100a8c51b3fSopenharmony_ci} 101a8c51b3fSopenharmony_ciBENCHMARK(BM_bytes_per_second); 102a8c51b3fSopenharmony_ci 103a8c51b3fSopenharmony_ciADD_CASES(TC_ConsoleOut, {{"^BM_bytes_per_second %console_report " 104a8c51b3fSopenharmony_ci "bytes_per_second=%float[kM]{0,1}/s$"}}); 105a8c51b3fSopenharmony_ciADD_CASES(TC_JSONOut, {{"\"name\": \"BM_bytes_per_second\",$"}, 106a8c51b3fSopenharmony_ci {"\"family_index\": 1,$", MR_Next}, 107a8c51b3fSopenharmony_ci {"\"per_family_instance_index\": 0,$", MR_Next}, 108a8c51b3fSopenharmony_ci {"\"run_name\": \"BM_bytes_per_second\",$", MR_Next}, 109a8c51b3fSopenharmony_ci {"\"run_type\": \"iteration\",$", MR_Next}, 110a8c51b3fSopenharmony_ci {"\"repetitions\": 1,$", MR_Next}, 111a8c51b3fSopenharmony_ci {"\"repetition_index\": 0,$", MR_Next}, 112a8c51b3fSopenharmony_ci {"\"threads\": 1,$", MR_Next}, 113a8c51b3fSopenharmony_ci {"\"iterations\": %int,$", MR_Next}, 114a8c51b3fSopenharmony_ci {"\"real_time\": %float,$", MR_Next}, 115a8c51b3fSopenharmony_ci {"\"cpu_time\": %float,$", MR_Next}, 116a8c51b3fSopenharmony_ci {"\"time_unit\": \"ns\",$", MR_Next}, 117a8c51b3fSopenharmony_ci {"\"bytes_per_second\": %float$", MR_Next}, 118a8c51b3fSopenharmony_ci {"}", MR_Next}}); 119a8c51b3fSopenharmony_ciADD_CASES(TC_CSVOut, {{"^\"BM_bytes_per_second\",%csv_bytes_report$"}}); 120a8c51b3fSopenharmony_ci 121a8c51b3fSopenharmony_ci// ========================================================================= // 122a8c51b3fSopenharmony_ci// ------------------------ Testing Items per Second Output ---------------- // 123a8c51b3fSopenharmony_ci// ========================================================================= // 124a8c51b3fSopenharmony_ci 125a8c51b3fSopenharmony_civoid BM_items_per_second(benchmark::State& state) { 126a8c51b3fSopenharmony_ci for (auto _ : state) { 127a8c51b3fSopenharmony_ci // This test requires a non-zero CPU time to avoid divide-by-zero 128a8c51b3fSopenharmony_ci auto iterations = state.iterations(); 129a8c51b3fSopenharmony_ci benchmark::DoNotOptimize(iterations); 130a8c51b3fSopenharmony_ci } 131a8c51b3fSopenharmony_ci state.SetItemsProcessed(1); 132a8c51b3fSopenharmony_ci} 133a8c51b3fSopenharmony_ciBENCHMARK(BM_items_per_second); 134a8c51b3fSopenharmony_ci 135a8c51b3fSopenharmony_ciADD_CASES(TC_ConsoleOut, {{"^BM_items_per_second %console_report " 136a8c51b3fSopenharmony_ci "items_per_second=%float[kM]{0,1}/s$"}}); 137a8c51b3fSopenharmony_ciADD_CASES(TC_JSONOut, {{"\"name\": \"BM_items_per_second\",$"}, 138a8c51b3fSopenharmony_ci {"\"family_index\": 2,$", MR_Next}, 139a8c51b3fSopenharmony_ci {"\"per_family_instance_index\": 0,$", MR_Next}, 140a8c51b3fSopenharmony_ci {"\"run_name\": \"BM_items_per_second\",$", MR_Next}, 141a8c51b3fSopenharmony_ci {"\"run_type\": \"iteration\",$", MR_Next}, 142a8c51b3fSopenharmony_ci {"\"repetitions\": 1,$", MR_Next}, 143a8c51b3fSopenharmony_ci {"\"repetition_index\": 0,$", MR_Next}, 144a8c51b3fSopenharmony_ci {"\"threads\": 1,$", MR_Next}, 145a8c51b3fSopenharmony_ci {"\"iterations\": %int,$", MR_Next}, 146a8c51b3fSopenharmony_ci {"\"real_time\": %float,$", MR_Next}, 147a8c51b3fSopenharmony_ci {"\"cpu_time\": %float,$", MR_Next}, 148a8c51b3fSopenharmony_ci {"\"time_unit\": \"ns\",$", MR_Next}, 149a8c51b3fSopenharmony_ci {"\"items_per_second\": %float$", MR_Next}, 150a8c51b3fSopenharmony_ci {"}", MR_Next}}); 151a8c51b3fSopenharmony_ciADD_CASES(TC_CSVOut, {{"^\"BM_items_per_second\",%csv_items_report$"}}); 152a8c51b3fSopenharmony_ci 153a8c51b3fSopenharmony_ci// ========================================================================= // 154a8c51b3fSopenharmony_ci// ------------------------ Testing Label Output --------------------------- // 155a8c51b3fSopenharmony_ci// ========================================================================= // 156a8c51b3fSopenharmony_ci 157a8c51b3fSopenharmony_civoid BM_label(benchmark::State& state) { 158a8c51b3fSopenharmony_ci for (auto _ : state) { 159a8c51b3fSopenharmony_ci } 160a8c51b3fSopenharmony_ci state.SetLabel("some label"); 161a8c51b3fSopenharmony_ci} 162a8c51b3fSopenharmony_ciBENCHMARK(BM_label); 163a8c51b3fSopenharmony_ci 164a8c51b3fSopenharmony_ciADD_CASES(TC_ConsoleOut, {{"^BM_label %console_report some label$"}}); 165a8c51b3fSopenharmony_ciADD_CASES(TC_JSONOut, {{"\"name\": \"BM_label\",$"}, 166a8c51b3fSopenharmony_ci {"\"family_index\": 3,$", MR_Next}, 167a8c51b3fSopenharmony_ci {"\"per_family_instance_index\": 0,$", MR_Next}, 168a8c51b3fSopenharmony_ci {"\"run_name\": \"BM_label\",$", MR_Next}, 169a8c51b3fSopenharmony_ci {"\"run_type\": \"iteration\",$", MR_Next}, 170a8c51b3fSopenharmony_ci {"\"repetitions\": 1,$", MR_Next}, 171a8c51b3fSopenharmony_ci {"\"repetition_index\": 0,$", MR_Next}, 172a8c51b3fSopenharmony_ci {"\"threads\": 1,$", MR_Next}, 173a8c51b3fSopenharmony_ci {"\"iterations\": %int,$", MR_Next}, 174a8c51b3fSopenharmony_ci {"\"real_time\": %float,$", MR_Next}, 175a8c51b3fSopenharmony_ci {"\"cpu_time\": %float,$", MR_Next}, 176a8c51b3fSopenharmony_ci {"\"time_unit\": \"ns\",$", MR_Next}, 177a8c51b3fSopenharmony_ci {"\"label\": \"some label\"$", MR_Next}, 178a8c51b3fSopenharmony_ci {"}", MR_Next}}); 179a8c51b3fSopenharmony_ciADD_CASES(TC_CSVOut, {{"^\"BM_label\",%csv_label_report_begin\"some " 180a8c51b3fSopenharmony_ci "label\"%csv_label_report_end$"}}); 181a8c51b3fSopenharmony_ci 182a8c51b3fSopenharmony_ci// ========================================================================= // 183a8c51b3fSopenharmony_ci// ------------------------ Testing Time Label Output ---------------------- // 184a8c51b3fSopenharmony_ci// ========================================================================= // 185a8c51b3fSopenharmony_ci 186a8c51b3fSopenharmony_civoid BM_time_label_nanosecond(benchmark::State& state) { 187a8c51b3fSopenharmony_ci for (auto _ : state) { 188a8c51b3fSopenharmony_ci } 189a8c51b3fSopenharmony_ci} 190a8c51b3fSopenharmony_ciBENCHMARK(BM_time_label_nanosecond)->Unit(benchmark::kNanosecond); 191a8c51b3fSopenharmony_ci 192a8c51b3fSopenharmony_ciADD_CASES(TC_ConsoleOut, {{"^BM_time_label_nanosecond %console_report$"}}); 193a8c51b3fSopenharmony_ciADD_CASES(TC_JSONOut, 194a8c51b3fSopenharmony_ci {{"\"name\": \"BM_time_label_nanosecond\",$"}, 195a8c51b3fSopenharmony_ci {"\"family_index\": 4,$", MR_Next}, 196a8c51b3fSopenharmony_ci {"\"per_family_instance_index\": 0,$", MR_Next}, 197a8c51b3fSopenharmony_ci {"\"run_name\": \"BM_time_label_nanosecond\",$", MR_Next}, 198a8c51b3fSopenharmony_ci {"\"run_type\": \"iteration\",$", MR_Next}, 199a8c51b3fSopenharmony_ci {"\"repetitions\": 1,$", MR_Next}, 200a8c51b3fSopenharmony_ci {"\"repetition_index\": 0,$", MR_Next}, 201a8c51b3fSopenharmony_ci {"\"threads\": 1,$", MR_Next}, 202a8c51b3fSopenharmony_ci {"\"iterations\": %int,$", MR_Next}, 203a8c51b3fSopenharmony_ci {"\"real_time\": %float,$", MR_Next}, 204a8c51b3fSopenharmony_ci {"\"cpu_time\": %float,$", MR_Next}, 205a8c51b3fSopenharmony_ci {"\"time_unit\": \"ns\"$", MR_Next}, 206a8c51b3fSopenharmony_ci {"}", MR_Next}}); 207a8c51b3fSopenharmony_ciADD_CASES(TC_CSVOut, {{"^\"BM_time_label_nanosecond\",%csv_report$"}}); 208a8c51b3fSopenharmony_ci 209a8c51b3fSopenharmony_civoid BM_time_label_microsecond(benchmark::State& state) { 210a8c51b3fSopenharmony_ci for (auto _ : state) { 211a8c51b3fSopenharmony_ci } 212a8c51b3fSopenharmony_ci} 213a8c51b3fSopenharmony_ciBENCHMARK(BM_time_label_microsecond)->Unit(benchmark::kMicrosecond); 214a8c51b3fSopenharmony_ci 215a8c51b3fSopenharmony_ciADD_CASES(TC_ConsoleOut, {{"^BM_time_label_microsecond %console_us_report$"}}); 216a8c51b3fSopenharmony_ciADD_CASES(TC_JSONOut, 217a8c51b3fSopenharmony_ci {{"\"name\": \"BM_time_label_microsecond\",$"}, 218a8c51b3fSopenharmony_ci {"\"family_index\": 5,$", MR_Next}, 219a8c51b3fSopenharmony_ci {"\"per_family_instance_index\": 0,$", MR_Next}, 220a8c51b3fSopenharmony_ci {"\"run_name\": \"BM_time_label_microsecond\",$", MR_Next}, 221a8c51b3fSopenharmony_ci {"\"run_type\": \"iteration\",$", MR_Next}, 222a8c51b3fSopenharmony_ci {"\"repetitions\": 1,$", MR_Next}, 223a8c51b3fSopenharmony_ci {"\"repetition_index\": 0,$", MR_Next}, 224a8c51b3fSopenharmony_ci {"\"threads\": 1,$", MR_Next}, 225a8c51b3fSopenharmony_ci {"\"iterations\": %int,$", MR_Next}, 226a8c51b3fSopenharmony_ci {"\"real_time\": %float,$", MR_Next}, 227a8c51b3fSopenharmony_ci {"\"cpu_time\": %float,$", MR_Next}, 228a8c51b3fSopenharmony_ci {"\"time_unit\": \"us\"$", MR_Next}, 229a8c51b3fSopenharmony_ci {"}", MR_Next}}); 230a8c51b3fSopenharmony_ciADD_CASES(TC_CSVOut, {{"^\"BM_time_label_microsecond\",%csv_us_report$"}}); 231a8c51b3fSopenharmony_ci 232a8c51b3fSopenharmony_civoid BM_time_label_millisecond(benchmark::State& state) { 233a8c51b3fSopenharmony_ci for (auto _ : state) { 234a8c51b3fSopenharmony_ci } 235a8c51b3fSopenharmony_ci} 236a8c51b3fSopenharmony_ciBENCHMARK(BM_time_label_millisecond)->Unit(benchmark::kMillisecond); 237a8c51b3fSopenharmony_ci 238a8c51b3fSopenharmony_ciADD_CASES(TC_ConsoleOut, {{"^BM_time_label_millisecond %console_ms_report$"}}); 239a8c51b3fSopenharmony_ciADD_CASES(TC_JSONOut, 240a8c51b3fSopenharmony_ci {{"\"name\": \"BM_time_label_millisecond\",$"}, 241a8c51b3fSopenharmony_ci {"\"family_index\": 6,$", MR_Next}, 242a8c51b3fSopenharmony_ci {"\"per_family_instance_index\": 0,$", MR_Next}, 243a8c51b3fSopenharmony_ci {"\"run_name\": \"BM_time_label_millisecond\",$", MR_Next}, 244a8c51b3fSopenharmony_ci {"\"run_type\": \"iteration\",$", MR_Next}, 245a8c51b3fSopenharmony_ci {"\"repetitions\": 1,$", MR_Next}, 246a8c51b3fSopenharmony_ci {"\"repetition_index\": 0,$", MR_Next}, 247a8c51b3fSopenharmony_ci {"\"threads\": 1,$", MR_Next}, 248a8c51b3fSopenharmony_ci {"\"iterations\": %int,$", MR_Next}, 249a8c51b3fSopenharmony_ci {"\"real_time\": %float,$", MR_Next}, 250a8c51b3fSopenharmony_ci {"\"cpu_time\": %float,$", MR_Next}, 251a8c51b3fSopenharmony_ci {"\"time_unit\": \"ms\"$", MR_Next}, 252a8c51b3fSopenharmony_ci {"}", MR_Next}}); 253a8c51b3fSopenharmony_ciADD_CASES(TC_CSVOut, {{"^\"BM_time_label_millisecond\",%csv_ms_report$"}}); 254a8c51b3fSopenharmony_ci 255a8c51b3fSopenharmony_civoid BM_time_label_second(benchmark::State& state) { 256a8c51b3fSopenharmony_ci for (auto _ : state) { 257a8c51b3fSopenharmony_ci } 258a8c51b3fSopenharmony_ci} 259a8c51b3fSopenharmony_ciBENCHMARK(BM_time_label_second)->Unit(benchmark::kSecond); 260a8c51b3fSopenharmony_ci 261a8c51b3fSopenharmony_ciADD_CASES(TC_ConsoleOut, {{"^BM_time_label_second %console_s_report$"}}); 262a8c51b3fSopenharmony_ciADD_CASES(TC_JSONOut, {{"\"name\": \"BM_time_label_second\",$"}, 263a8c51b3fSopenharmony_ci {"\"family_index\": 7,$", MR_Next}, 264a8c51b3fSopenharmony_ci {"\"per_family_instance_index\": 0,$", MR_Next}, 265a8c51b3fSopenharmony_ci {"\"run_name\": \"BM_time_label_second\",$", MR_Next}, 266a8c51b3fSopenharmony_ci {"\"run_type\": \"iteration\",$", MR_Next}, 267a8c51b3fSopenharmony_ci {"\"repetitions\": 1,$", MR_Next}, 268a8c51b3fSopenharmony_ci {"\"repetition_index\": 0,$", MR_Next}, 269a8c51b3fSopenharmony_ci {"\"threads\": 1,$", MR_Next}, 270a8c51b3fSopenharmony_ci {"\"iterations\": %int,$", MR_Next}, 271a8c51b3fSopenharmony_ci {"\"real_time\": %float,$", MR_Next}, 272a8c51b3fSopenharmony_ci {"\"cpu_time\": %float,$", MR_Next}, 273a8c51b3fSopenharmony_ci {"\"time_unit\": \"s\"$", MR_Next}, 274a8c51b3fSopenharmony_ci {"}", MR_Next}}); 275a8c51b3fSopenharmony_ciADD_CASES(TC_CSVOut, {{"^\"BM_time_label_second\",%csv_s_report$"}}); 276a8c51b3fSopenharmony_ci 277a8c51b3fSopenharmony_ci// ========================================================================= // 278a8c51b3fSopenharmony_ci// ------------------------ Testing Error Output --------------------------- // 279a8c51b3fSopenharmony_ci// ========================================================================= // 280a8c51b3fSopenharmony_ci 281a8c51b3fSopenharmony_civoid BM_error(benchmark::State& state) { 282a8c51b3fSopenharmony_ci state.SkipWithError("message"); 283a8c51b3fSopenharmony_ci for (auto _ : state) { 284a8c51b3fSopenharmony_ci } 285a8c51b3fSopenharmony_ci} 286a8c51b3fSopenharmony_ciBENCHMARK(BM_error); 287a8c51b3fSopenharmony_ciADD_CASES(TC_ConsoleOut, {{"^BM_error[ ]+ERROR OCCURRED: 'message'$"}}); 288a8c51b3fSopenharmony_ciADD_CASES(TC_JSONOut, {{"\"name\": \"BM_error\",$"}, 289a8c51b3fSopenharmony_ci {"\"family_index\": 8,$", MR_Next}, 290a8c51b3fSopenharmony_ci {"\"per_family_instance_index\": 0,$", MR_Next}, 291a8c51b3fSopenharmony_ci {"\"run_name\": \"BM_error\",$", MR_Next}, 292a8c51b3fSopenharmony_ci {"\"run_type\": \"iteration\",$", MR_Next}, 293a8c51b3fSopenharmony_ci {"\"repetitions\": 1,$", MR_Next}, 294a8c51b3fSopenharmony_ci {"\"repetition_index\": 0,$", MR_Next}, 295a8c51b3fSopenharmony_ci {"\"threads\": 1,$", MR_Next}, 296a8c51b3fSopenharmony_ci {"\"error_occurred\": true,$", MR_Next}, 297a8c51b3fSopenharmony_ci {"\"error_message\": \"message\",$", MR_Next}}); 298a8c51b3fSopenharmony_ci 299a8c51b3fSopenharmony_ciADD_CASES(TC_CSVOut, {{"^\"BM_error\",,,,,,,,true,\"message\"$"}}); 300a8c51b3fSopenharmony_ci 301a8c51b3fSopenharmony_ci// ========================================================================= // 302a8c51b3fSopenharmony_ci// ------------------------ Testing No Arg Name Output ----------------------- 303a8c51b3fSopenharmony_ci// // 304a8c51b3fSopenharmony_ci// ========================================================================= // 305a8c51b3fSopenharmony_ci 306a8c51b3fSopenharmony_civoid BM_no_arg_name(benchmark::State& state) { 307a8c51b3fSopenharmony_ci for (auto _ : state) { 308a8c51b3fSopenharmony_ci } 309a8c51b3fSopenharmony_ci} 310a8c51b3fSopenharmony_ciBENCHMARK(BM_no_arg_name)->Arg(3); 311a8c51b3fSopenharmony_ciADD_CASES(TC_ConsoleOut, {{"^BM_no_arg_name/3 %console_report$"}}); 312a8c51b3fSopenharmony_ciADD_CASES(TC_JSONOut, {{"\"name\": \"BM_no_arg_name/3\",$"}, 313a8c51b3fSopenharmony_ci {"\"family_index\": 9,$", MR_Next}, 314a8c51b3fSopenharmony_ci {"\"per_family_instance_index\": 0,$", MR_Next}, 315a8c51b3fSopenharmony_ci {"\"run_name\": \"BM_no_arg_name/3\",$", MR_Next}, 316a8c51b3fSopenharmony_ci {"\"run_type\": \"iteration\",$", MR_Next}, 317a8c51b3fSopenharmony_ci {"\"repetitions\": 1,$", MR_Next}, 318a8c51b3fSopenharmony_ci {"\"repetition_index\": 0,$", MR_Next}, 319a8c51b3fSopenharmony_ci {"\"threads\": 1,$", MR_Next}}); 320a8c51b3fSopenharmony_ciADD_CASES(TC_CSVOut, {{"^\"BM_no_arg_name/3\",%csv_report$"}}); 321a8c51b3fSopenharmony_ci 322a8c51b3fSopenharmony_ci// ========================================================================= // 323a8c51b3fSopenharmony_ci// ------------------------ Testing Arg Name Output ------------------------ // 324a8c51b3fSopenharmony_ci// ========================================================================= // 325a8c51b3fSopenharmony_ci 326a8c51b3fSopenharmony_civoid BM_arg_name(benchmark::State& state) { 327a8c51b3fSopenharmony_ci for (auto _ : state) { 328a8c51b3fSopenharmony_ci } 329a8c51b3fSopenharmony_ci} 330a8c51b3fSopenharmony_ciBENCHMARK(BM_arg_name)->ArgName("first")->Arg(3); 331a8c51b3fSopenharmony_ciADD_CASES(TC_ConsoleOut, {{"^BM_arg_name/first:3 %console_report$"}}); 332a8c51b3fSopenharmony_ciADD_CASES(TC_JSONOut, {{"\"name\": \"BM_arg_name/first:3\",$"}, 333a8c51b3fSopenharmony_ci {"\"family_index\": 10,$", MR_Next}, 334a8c51b3fSopenharmony_ci {"\"per_family_instance_index\": 0,$", MR_Next}, 335a8c51b3fSopenharmony_ci {"\"run_name\": \"BM_arg_name/first:3\",$", MR_Next}, 336a8c51b3fSopenharmony_ci {"\"run_type\": \"iteration\",$", MR_Next}, 337a8c51b3fSopenharmony_ci {"\"repetitions\": 1,$", MR_Next}, 338a8c51b3fSopenharmony_ci {"\"repetition_index\": 0,$", MR_Next}, 339a8c51b3fSopenharmony_ci {"\"threads\": 1,$", MR_Next}}); 340a8c51b3fSopenharmony_ciADD_CASES(TC_CSVOut, {{"^\"BM_arg_name/first:3\",%csv_report$"}}); 341a8c51b3fSopenharmony_ci 342a8c51b3fSopenharmony_ci// ========================================================================= // 343a8c51b3fSopenharmony_ci// ------------------------ Testing Arg Names Output ----------------------- // 344a8c51b3fSopenharmony_ci// ========================================================================= // 345a8c51b3fSopenharmony_ci 346a8c51b3fSopenharmony_civoid BM_arg_names(benchmark::State& state) { 347a8c51b3fSopenharmony_ci for (auto _ : state) { 348a8c51b3fSopenharmony_ci } 349a8c51b3fSopenharmony_ci} 350a8c51b3fSopenharmony_ciBENCHMARK(BM_arg_names)->Args({2, 5, 4})->ArgNames({"first", "", "third"}); 351a8c51b3fSopenharmony_ciADD_CASES(TC_ConsoleOut, 352a8c51b3fSopenharmony_ci {{"^BM_arg_names/first:2/5/third:4 %console_report$"}}); 353a8c51b3fSopenharmony_ciADD_CASES(TC_JSONOut, 354a8c51b3fSopenharmony_ci {{"\"name\": \"BM_arg_names/first:2/5/third:4\",$"}, 355a8c51b3fSopenharmony_ci {"\"family_index\": 11,$", MR_Next}, 356a8c51b3fSopenharmony_ci {"\"per_family_instance_index\": 0,$", MR_Next}, 357a8c51b3fSopenharmony_ci {"\"run_name\": \"BM_arg_names/first:2/5/third:4\",$", MR_Next}, 358a8c51b3fSopenharmony_ci {"\"run_type\": \"iteration\",$", MR_Next}, 359a8c51b3fSopenharmony_ci {"\"repetitions\": 1,$", MR_Next}, 360a8c51b3fSopenharmony_ci {"\"repetition_index\": 0,$", MR_Next}, 361a8c51b3fSopenharmony_ci {"\"threads\": 1,$", MR_Next}}); 362a8c51b3fSopenharmony_ciADD_CASES(TC_CSVOut, {{"^\"BM_arg_names/first:2/5/third:4\",%csv_report$"}}); 363a8c51b3fSopenharmony_ci 364a8c51b3fSopenharmony_ci// ========================================================================= // 365a8c51b3fSopenharmony_ci// ------------------------ Testing Name Output ---------------------------- // 366a8c51b3fSopenharmony_ci// ========================================================================= // 367a8c51b3fSopenharmony_ci 368a8c51b3fSopenharmony_civoid BM_name(benchmark::State& state) { 369a8c51b3fSopenharmony_ci for (auto _ : state) { 370a8c51b3fSopenharmony_ci } 371a8c51b3fSopenharmony_ci} 372a8c51b3fSopenharmony_ciBENCHMARK(BM_name)->Name("BM_custom_name"); 373a8c51b3fSopenharmony_ci 374a8c51b3fSopenharmony_ciADD_CASES(TC_ConsoleOut, {{"^BM_custom_name %console_report$"}}); 375a8c51b3fSopenharmony_ciADD_CASES(TC_JSONOut, {{"\"name\": \"BM_custom_name\",$"}, 376a8c51b3fSopenharmony_ci {"\"family_index\": 12,$", MR_Next}, 377a8c51b3fSopenharmony_ci {"\"per_family_instance_index\": 0,$", MR_Next}, 378a8c51b3fSopenharmony_ci {"\"run_name\": \"BM_custom_name\",$", MR_Next}, 379a8c51b3fSopenharmony_ci {"\"run_type\": \"iteration\",$", MR_Next}, 380a8c51b3fSopenharmony_ci {"\"repetitions\": 1,$", MR_Next}, 381a8c51b3fSopenharmony_ci {"\"repetition_index\": 0,$", MR_Next}, 382a8c51b3fSopenharmony_ci {"\"threads\": 1,$", MR_Next}, 383a8c51b3fSopenharmony_ci {"\"iterations\": %int,$", MR_Next}, 384a8c51b3fSopenharmony_ci {"\"real_time\": %float,$", MR_Next}, 385a8c51b3fSopenharmony_ci {"\"cpu_time\": %float,$", MR_Next}, 386a8c51b3fSopenharmony_ci {"\"time_unit\": \"ns\"$", MR_Next}, 387a8c51b3fSopenharmony_ci {"}", MR_Next}}); 388a8c51b3fSopenharmony_ciADD_CASES(TC_CSVOut, {{"^\"BM_custom_name\",%csv_report$"}}); 389a8c51b3fSopenharmony_ci 390a8c51b3fSopenharmony_ci// ========================================================================= // 391a8c51b3fSopenharmony_ci// ------------------------ Testing Big Args Output ------------------------ // 392a8c51b3fSopenharmony_ci// ========================================================================= // 393a8c51b3fSopenharmony_ci 394a8c51b3fSopenharmony_civoid BM_BigArgs(benchmark::State& state) { 395a8c51b3fSopenharmony_ci for (auto _ : state) { 396a8c51b3fSopenharmony_ci } 397a8c51b3fSopenharmony_ci} 398a8c51b3fSopenharmony_ciBENCHMARK(BM_BigArgs)->RangeMultiplier(2)->Range(1U << 30U, 1U << 31U); 399a8c51b3fSopenharmony_ciADD_CASES(TC_ConsoleOut, {{"^BM_BigArgs/1073741824 %console_report$"}, 400a8c51b3fSopenharmony_ci {"^BM_BigArgs/2147483648 %console_report$"}}); 401a8c51b3fSopenharmony_ci 402a8c51b3fSopenharmony_ci// ========================================================================= // 403a8c51b3fSopenharmony_ci// ----------------------- Testing Complexity Output ----------------------- // 404a8c51b3fSopenharmony_ci// ========================================================================= // 405a8c51b3fSopenharmony_ci 406a8c51b3fSopenharmony_civoid BM_Complexity_O1(benchmark::State& state) { 407a8c51b3fSopenharmony_ci for (auto _ : state) { 408a8c51b3fSopenharmony_ci // This test requires a non-zero CPU time to avoid divide-by-zero 409a8c51b3fSopenharmony_ci auto iterations = state.iterations(); 410a8c51b3fSopenharmony_ci benchmark::DoNotOptimize(iterations); 411a8c51b3fSopenharmony_ci } 412a8c51b3fSopenharmony_ci state.SetComplexityN(state.range(0)); 413a8c51b3fSopenharmony_ci} 414a8c51b3fSopenharmony_ciBENCHMARK(BM_Complexity_O1)->Range(1, 1 << 18)->Complexity(benchmark::o1); 415a8c51b3fSopenharmony_ciSET_SUBSTITUTIONS({{"%bigOStr", "[ ]* %float \\([0-9]+\\)"}, 416a8c51b3fSopenharmony_ci {"%RMS", "[ ]*[0-9]+ %"}}); 417a8c51b3fSopenharmony_ciADD_CASES(TC_ConsoleOut, {{"^BM_Complexity_O1_BigO %bigOStr %bigOStr[ ]*$"}, 418a8c51b3fSopenharmony_ci {"^BM_Complexity_O1_RMS %RMS %RMS[ ]*$"}}); 419a8c51b3fSopenharmony_ci 420a8c51b3fSopenharmony_ci// ========================================================================= // 421a8c51b3fSopenharmony_ci// ----------------------- Testing Aggregate Output ------------------------ // 422a8c51b3fSopenharmony_ci// ========================================================================= // 423a8c51b3fSopenharmony_ci 424a8c51b3fSopenharmony_ci// Test that non-aggregate data is printed by default 425a8c51b3fSopenharmony_civoid BM_Repeat(benchmark::State& state) { 426a8c51b3fSopenharmony_ci for (auto _ : state) { 427a8c51b3fSopenharmony_ci } 428a8c51b3fSopenharmony_ci} 429a8c51b3fSopenharmony_ci// need two repetitions min to be able to output any aggregate output 430a8c51b3fSopenharmony_ciBENCHMARK(BM_Repeat)->Repetitions(2); 431a8c51b3fSopenharmony_ciADD_CASES(TC_ConsoleOut, 432a8c51b3fSopenharmony_ci {{"^BM_Repeat/repeats:2 %console_report$"}, 433a8c51b3fSopenharmony_ci {"^BM_Repeat/repeats:2 %console_report$"}, 434a8c51b3fSopenharmony_ci {"^BM_Repeat/repeats:2_mean %console_time_only_report [ ]*2$"}, 435a8c51b3fSopenharmony_ci {"^BM_Repeat/repeats:2_median %console_time_only_report [ ]*2$"}, 436a8c51b3fSopenharmony_ci {"^BM_Repeat/repeats:2_stddev %console_time_only_report [ ]*2$"}}); 437a8c51b3fSopenharmony_ciADD_CASES(TC_JSONOut, {{"\"name\": \"BM_Repeat/repeats:2\",$"}, 438a8c51b3fSopenharmony_ci {"\"family_index\": 15,$", MR_Next}, 439a8c51b3fSopenharmony_ci {"\"per_family_instance_index\": 0,$", MR_Next}, 440a8c51b3fSopenharmony_ci {"\"run_name\": \"BM_Repeat/repeats:2\"", MR_Next}, 441a8c51b3fSopenharmony_ci {"\"run_type\": \"iteration\",$", MR_Next}, 442a8c51b3fSopenharmony_ci {"\"repetitions\": 2,$", MR_Next}, 443a8c51b3fSopenharmony_ci {"\"repetition_index\": 0,$", MR_Next}, 444a8c51b3fSopenharmony_ci {"\"threads\": 1,$", MR_Next}, 445a8c51b3fSopenharmony_ci {"\"name\": \"BM_Repeat/repeats:2\",$"}, 446a8c51b3fSopenharmony_ci {"\"family_index\": 15,$", MR_Next}, 447a8c51b3fSopenharmony_ci {"\"per_family_instance_index\": 0,$", MR_Next}, 448a8c51b3fSopenharmony_ci {"\"run_name\": \"BM_Repeat/repeats:2\",$", MR_Next}, 449a8c51b3fSopenharmony_ci {"\"run_type\": \"iteration\",$", MR_Next}, 450a8c51b3fSopenharmony_ci {"\"repetitions\": 2,$", MR_Next}, 451a8c51b3fSopenharmony_ci {"\"repetition_index\": 1,$", MR_Next}, 452a8c51b3fSopenharmony_ci {"\"threads\": 1,$", MR_Next}, 453a8c51b3fSopenharmony_ci {"\"name\": \"BM_Repeat/repeats:2_mean\",$"}, 454a8c51b3fSopenharmony_ci {"\"family_index\": 15,$", MR_Next}, 455a8c51b3fSopenharmony_ci {"\"per_family_instance_index\": 0,$", MR_Next}, 456a8c51b3fSopenharmony_ci {"\"run_name\": \"BM_Repeat/repeats:2\",$", MR_Next}, 457a8c51b3fSopenharmony_ci {"\"run_type\": \"aggregate\",$", MR_Next}, 458a8c51b3fSopenharmony_ci {"\"repetitions\": 2,$", MR_Next}, 459a8c51b3fSopenharmony_ci {"\"threads\": 1,$", MR_Next}, 460a8c51b3fSopenharmony_ci {"\"aggregate_name\": \"mean\",$", MR_Next}, 461a8c51b3fSopenharmony_ci {"\"aggregate_unit\": \"time\",$", MR_Next}, 462a8c51b3fSopenharmony_ci {"\"iterations\": 2,$", MR_Next}, 463a8c51b3fSopenharmony_ci {"\"name\": \"BM_Repeat/repeats:2_median\",$"}, 464a8c51b3fSopenharmony_ci {"\"family_index\": 15,$", MR_Next}, 465a8c51b3fSopenharmony_ci {"\"per_family_instance_index\": 0,$", MR_Next}, 466a8c51b3fSopenharmony_ci {"\"run_name\": \"BM_Repeat/repeats:2\",$", MR_Next}, 467a8c51b3fSopenharmony_ci {"\"run_type\": \"aggregate\",$", MR_Next}, 468a8c51b3fSopenharmony_ci {"\"repetitions\": 2,$", MR_Next}, 469a8c51b3fSopenharmony_ci {"\"threads\": 1,$", MR_Next}, 470a8c51b3fSopenharmony_ci {"\"aggregate_name\": \"median\",$", MR_Next}, 471a8c51b3fSopenharmony_ci {"\"aggregate_unit\": \"time\",$", MR_Next}, 472a8c51b3fSopenharmony_ci {"\"iterations\": 2,$", MR_Next}, 473a8c51b3fSopenharmony_ci {"\"name\": \"BM_Repeat/repeats:2_stddev\",$"}, 474a8c51b3fSopenharmony_ci {"\"family_index\": 15,$", MR_Next}, 475a8c51b3fSopenharmony_ci {"\"per_family_instance_index\": 0,$", MR_Next}, 476a8c51b3fSopenharmony_ci {"\"run_name\": \"BM_Repeat/repeats:2\",$", MR_Next}, 477a8c51b3fSopenharmony_ci {"\"run_type\": \"aggregate\",$", MR_Next}, 478a8c51b3fSopenharmony_ci {"\"repetitions\": 2,$", MR_Next}, 479a8c51b3fSopenharmony_ci {"\"threads\": 1,$", MR_Next}, 480a8c51b3fSopenharmony_ci {"\"aggregate_name\": \"stddev\",$", MR_Next}, 481a8c51b3fSopenharmony_ci {"\"aggregate_unit\": \"time\",$", MR_Next}, 482a8c51b3fSopenharmony_ci {"\"iterations\": 2,$", MR_Next}}); 483a8c51b3fSopenharmony_ciADD_CASES(TC_CSVOut, {{"^\"BM_Repeat/repeats:2\",%csv_report$"}, 484a8c51b3fSopenharmony_ci {"^\"BM_Repeat/repeats:2\",%csv_report$"}, 485a8c51b3fSopenharmony_ci {"^\"BM_Repeat/repeats:2_mean\",%csv_report$"}, 486a8c51b3fSopenharmony_ci {"^\"BM_Repeat/repeats:2_median\",%csv_report$"}, 487a8c51b3fSopenharmony_ci {"^\"BM_Repeat/repeats:2_stddev\",%csv_report$"}}); 488a8c51b3fSopenharmony_ci// but for two repetitions, mean and median is the same, so let's repeat.. 489a8c51b3fSopenharmony_ciBENCHMARK(BM_Repeat)->Repetitions(3); 490a8c51b3fSopenharmony_ciADD_CASES(TC_ConsoleOut, 491a8c51b3fSopenharmony_ci {{"^BM_Repeat/repeats:3 %console_report$"}, 492a8c51b3fSopenharmony_ci {"^BM_Repeat/repeats:3 %console_report$"}, 493a8c51b3fSopenharmony_ci {"^BM_Repeat/repeats:3 %console_report$"}, 494a8c51b3fSopenharmony_ci {"^BM_Repeat/repeats:3_mean %console_time_only_report [ ]*3$"}, 495a8c51b3fSopenharmony_ci {"^BM_Repeat/repeats:3_median %console_time_only_report [ ]*3$"}, 496a8c51b3fSopenharmony_ci {"^BM_Repeat/repeats:3_stddev %console_time_only_report [ ]*3$"}}); 497a8c51b3fSopenharmony_ciADD_CASES(TC_JSONOut, {{"\"name\": \"BM_Repeat/repeats:3\",$"}, 498a8c51b3fSopenharmony_ci {"\"family_index\": 16,$", MR_Next}, 499a8c51b3fSopenharmony_ci {"\"per_family_instance_index\": 0,$", MR_Next}, 500a8c51b3fSopenharmony_ci {"\"run_name\": \"BM_Repeat/repeats:3\",$", MR_Next}, 501a8c51b3fSopenharmony_ci {"\"run_type\": \"iteration\",$", MR_Next}, 502a8c51b3fSopenharmony_ci {"\"repetitions\": 3,$", MR_Next}, 503a8c51b3fSopenharmony_ci {"\"repetition_index\": 0,$", MR_Next}, 504a8c51b3fSopenharmony_ci {"\"threads\": 1,$", MR_Next}, 505a8c51b3fSopenharmony_ci {"\"name\": \"BM_Repeat/repeats:3\",$"}, 506a8c51b3fSopenharmony_ci {"\"family_index\": 16,$", MR_Next}, 507a8c51b3fSopenharmony_ci {"\"per_family_instance_index\": 0,$", MR_Next}, 508a8c51b3fSopenharmony_ci {"\"run_name\": \"BM_Repeat/repeats:3\",$", MR_Next}, 509a8c51b3fSopenharmony_ci {"\"run_type\": \"iteration\",$", MR_Next}, 510a8c51b3fSopenharmony_ci {"\"repetitions\": 3,$", MR_Next}, 511a8c51b3fSopenharmony_ci {"\"repetition_index\": 1,$", MR_Next}, 512a8c51b3fSopenharmony_ci {"\"threads\": 1,$", MR_Next}, 513a8c51b3fSopenharmony_ci {"\"name\": \"BM_Repeat/repeats:3\",$"}, 514a8c51b3fSopenharmony_ci {"\"family_index\": 16,$", MR_Next}, 515a8c51b3fSopenharmony_ci {"\"per_family_instance_index\": 0,$", MR_Next}, 516a8c51b3fSopenharmony_ci {"\"run_name\": \"BM_Repeat/repeats:3\",$", MR_Next}, 517a8c51b3fSopenharmony_ci {"\"run_type\": \"iteration\",$", MR_Next}, 518a8c51b3fSopenharmony_ci {"\"repetitions\": 3,$", MR_Next}, 519a8c51b3fSopenharmony_ci {"\"repetition_index\": 2,$", MR_Next}, 520a8c51b3fSopenharmony_ci {"\"threads\": 1,$", MR_Next}, 521a8c51b3fSopenharmony_ci {"\"name\": \"BM_Repeat/repeats:3_mean\",$"}, 522a8c51b3fSopenharmony_ci {"\"family_index\": 16,$", MR_Next}, 523a8c51b3fSopenharmony_ci {"\"per_family_instance_index\": 0,$", MR_Next}, 524a8c51b3fSopenharmony_ci {"\"run_name\": \"BM_Repeat/repeats:3\",$", MR_Next}, 525a8c51b3fSopenharmony_ci {"\"run_type\": \"aggregate\",$", MR_Next}, 526a8c51b3fSopenharmony_ci {"\"repetitions\": 3,$", MR_Next}, 527a8c51b3fSopenharmony_ci {"\"threads\": 1,$", MR_Next}, 528a8c51b3fSopenharmony_ci {"\"aggregate_name\": \"mean\",$", MR_Next}, 529a8c51b3fSopenharmony_ci {"\"aggregate_unit\": \"time\",$", MR_Next}, 530a8c51b3fSopenharmony_ci {"\"iterations\": 3,$", MR_Next}, 531a8c51b3fSopenharmony_ci {"\"name\": \"BM_Repeat/repeats:3_median\",$"}, 532a8c51b3fSopenharmony_ci {"\"family_index\": 16,$", MR_Next}, 533a8c51b3fSopenharmony_ci {"\"per_family_instance_index\": 0,$", MR_Next}, 534a8c51b3fSopenharmony_ci {"\"run_name\": \"BM_Repeat/repeats:3\",$", MR_Next}, 535a8c51b3fSopenharmony_ci {"\"run_type\": \"aggregate\",$", MR_Next}, 536a8c51b3fSopenharmony_ci {"\"repetitions\": 3,$", MR_Next}, 537a8c51b3fSopenharmony_ci {"\"threads\": 1,$", MR_Next}, 538a8c51b3fSopenharmony_ci {"\"aggregate_name\": \"median\",$", MR_Next}, 539a8c51b3fSopenharmony_ci {"\"aggregate_unit\": \"time\",$", MR_Next}, 540a8c51b3fSopenharmony_ci {"\"iterations\": 3,$", MR_Next}, 541a8c51b3fSopenharmony_ci {"\"name\": \"BM_Repeat/repeats:3_stddev\",$"}, 542a8c51b3fSopenharmony_ci {"\"family_index\": 16,$", MR_Next}, 543a8c51b3fSopenharmony_ci {"\"per_family_instance_index\": 0,$", MR_Next}, 544a8c51b3fSopenharmony_ci {"\"run_name\": \"BM_Repeat/repeats:3\",$", MR_Next}, 545a8c51b3fSopenharmony_ci {"\"run_type\": \"aggregate\",$", MR_Next}, 546a8c51b3fSopenharmony_ci {"\"repetitions\": 3,$", MR_Next}, 547a8c51b3fSopenharmony_ci {"\"threads\": 1,$", MR_Next}, 548a8c51b3fSopenharmony_ci {"\"aggregate_name\": \"stddev\",$", MR_Next}, 549a8c51b3fSopenharmony_ci {"\"aggregate_unit\": \"time\",$", MR_Next}, 550a8c51b3fSopenharmony_ci {"\"iterations\": 3,$", MR_Next}}); 551a8c51b3fSopenharmony_ciADD_CASES(TC_CSVOut, {{"^\"BM_Repeat/repeats:3\",%csv_report$"}, 552a8c51b3fSopenharmony_ci {"^\"BM_Repeat/repeats:3\",%csv_report$"}, 553a8c51b3fSopenharmony_ci {"^\"BM_Repeat/repeats:3\",%csv_report$"}, 554a8c51b3fSopenharmony_ci {"^\"BM_Repeat/repeats:3_mean\",%csv_report$"}, 555a8c51b3fSopenharmony_ci {"^\"BM_Repeat/repeats:3_median\",%csv_report$"}, 556a8c51b3fSopenharmony_ci {"^\"BM_Repeat/repeats:3_stddev\",%csv_report$"}}); 557a8c51b3fSopenharmony_ci// median differs between even/odd number of repetitions, so just to be sure 558a8c51b3fSopenharmony_ciBENCHMARK(BM_Repeat)->Repetitions(4); 559a8c51b3fSopenharmony_ciADD_CASES(TC_ConsoleOut, 560a8c51b3fSopenharmony_ci {{"^BM_Repeat/repeats:4 %console_report$"}, 561a8c51b3fSopenharmony_ci {"^BM_Repeat/repeats:4 %console_report$"}, 562a8c51b3fSopenharmony_ci {"^BM_Repeat/repeats:4 %console_report$"}, 563a8c51b3fSopenharmony_ci {"^BM_Repeat/repeats:4 %console_report$"}, 564a8c51b3fSopenharmony_ci {"^BM_Repeat/repeats:4_mean %console_time_only_report [ ]*4$"}, 565a8c51b3fSopenharmony_ci {"^BM_Repeat/repeats:4_median %console_time_only_report [ ]*4$"}, 566a8c51b3fSopenharmony_ci {"^BM_Repeat/repeats:4_stddev %console_time_only_report [ ]*4$"}}); 567a8c51b3fSopenharmony_ciADD_CASES(TC_JSONOut, {{"\"name\": \"BM_Repeat/repeats:4\",$"}, 568a8c51b3fSopenharmony_ci {"\"family_index\": 17,$", MR_Next}, 569a8c51b3fSopenharmony_ci {"\"per_family_instance_index\": 0,$", MR_Next}, 570a8c51b3fSopenharmony_ci {"\"run_name\": \"BM_Repeat/repeats:4\",$", MR_Next}, 571a8c51b3fSopenharmony_ci {"\"run_type\": \"iteration\",$", MR_Next}, 572a8c51b3fSopenharmony_ci {"\"repetitions\": 4,$", MR_Next}, 573a8c51b3fSopenharmony_ci {"\"repetition_index\": 0,$", MR_Next}, 574a8c51b3fSopenharmony_ci {"\"threads\": 1,$", MR_Next}, 575a8c51b3fSopenharmony_ci {"\"name\": \"BM_Repeat/repeats:4\",$"}, 576a8c51b3fSopenharmony_ci {"\"family_index\": 17,$", MR_Next}, 577a8c51b3fSopenharmony_ci {"\"per_family_instance_index\": 0,$", MR_Next}, 578a8c51b3fSopenharmony_ci {"\"run_name\": \"BM_Repeat/repeats:4\",$", MR_Next}, 579a8c51b3fSopenharmony_ci {"\"run_type\": \"iteration\",$", MR_Next}, 580a8c51b3fSopenharmony_ci {"\"repetitions\": 4,$", MR_Next}, 581a8c51b3fSopenharmony_ci {"\"repetition_index\": 1,$", MR_Next}, 582a8c51b3fSopenharmony_ci {"\"threads\": 1,$", MR_Next}, 583a8c51b3fSopenharmony_ci {"\"name\": \"BM_Repeat/repeats:4\",$"}, 584a8c51b3fSopenharmony_ci {"\"family_index\": 17,$", MR_Next}, 585a8c51b3fSopenharmony_ci {"\"per_family_instance_index\": 0,$", MR_Next}, 586a8c51b3fSopenharmony_ci {"\"run_name\": \"BM_Repeat/repeats:4\",$", MR_Next}, 587a8c51b3fSopenharmony_ci {"\"run_type\": \"iteration\",$", MR_Next}, 588a8c51b3fSopenharmony_ci {"\"repetitions\": 4,$", MR_Next}, 589a8c51b3fSopenharmony_ci {"\"repetition_index\": 2,$", MR_Next}, 590a8c51b3fSopenharmony_ci {"\"threads\": 1,$", MR_Next}, 591a8c51b3fSopenharmony_ci {"\"name\": \"BM_Repeat/repeats:4\",$"}, 592a8c51b3fSopenharmony_ci {"\"family_index\": 17,$", MR_Next}, 593a8c51b3fSopenharmony_ci {"\"per_family_instance_index\": 0,$", MR_Next}, 594a8c51b3fSopenharmony_ci {"\"run_name\": \"BM_Repeat/repeats:4\",$", MR_Next}, 595a8c51b3fSopenharmony_ci {"\"run_type\": \"iteration\",$", MR_Next}, 596a8c51b3fSopenharmony_ci {"\"repetitions\": 4,$", MR_Next}, 597a8c51b3fSopenharmony_ci {"\"repetition_index\": 3,$", MR_Next}, 598a8c51b3fSopenharmony_ci {"\"threads\": 1,$", MR_Next}, 599a8c51b3fSopenharmony_ci {"\"name\": \"BM_Repeat/repeats:4_mean\",$"}, 600a8c51b3fSopenharmony_ci {"\"family_index\": 17,$", MR_Next}, 601a8c51b3fSopenharmony_ci {"\"per_family_instance_index\": 0,$", MR_Next}, 602a8c51b3fSopenharmony_ci {"\"run_name\": \"BM_Repeat/repeats:4\",$", MR_Next}, 603a8c51b3fSopenharmony_ci {"\"run_type\": \"aggregate\",$", MR_Next}, 604a8c51b3fSopenharmony_ci {"\"repetitions\": 4,$", MR_Next}, 605a8c51b3fSopenharmony_ci {"\"threads\": 1,$", MR_Next}, 606a8c51b3fSopenharmony_ci {"\"aggregate_name\": \"mean\",$", MR_Next}, 607a8c51b3fSopenharmony_ci {"\"aggregate_unit\": \"time\",$", MR_Next}, 608a8c51b3fSopenharmony_ci {"\"iterations\": 4,$", MR_Next}, 609a8c51b3fSopenharmony_ci {"\"name\": \"BM_Repeat/repeats:4_median\",$"}, 610a8c51b3fSopenharmony_ci {"\"family_index\": 17,$", MR_Next}, 611a8c51b3fSopenharmony_ci {"\"per_family_instance_index\": 0,$", MR_Next}, 612a8c51b3fSopenharmony_ci {"\"run_name\": \"BM_Repeat/repeats:4\",$", MR_Next}, 613a8c51b3fSopenharmony_ci {"\"run_type\": \"aggregate\",$", MR_Next}, 614a8c51b3fSopenharmony_ci {"\"repetitions\": 4,$", MR_Next}, 615a8c51b3fSopenharmony_ci {"\"threads\": 1,$", MR_Next}, 616a8c51b3fSopenharmony_ci {"\"aggregate_name\": \"median\",$", MR_Next}, 617a8c51b3fSopenharmony_ci {"\"aggregate_unit\": \"time\",$", MR_Next}, 618a8c51b3fSopenharmony_ci {"\"iterations\": 4,$", MR_Next}, 619a8c51b3fSopenharmony_ci {"\"name\": \"BM_Repeat/repeats:4_stddev\",$"}, 620a8c51b3fSopenharmony_ci {"\"family_index\": 17,$", MR_Next}, 621a8c51b3fSopenharmony_ci {"\"per_family_instance_index\": 0,$", MR_Next}, 622a8c51b3fSopenharmony_ci {"\"run_name\": \"BM_Repeat/repeats:4\",$", MR_Next}, 623a8c51b3fSopenharmony_ci {"\"run_type\": \"aggregate\",$", MR_Next}, 624a8c51b3fSopenharmony_ci {"\"repetitions\": 4,$", MR_Next}, 625a8c51b3fSopenharmony_ci {"\"threads\": 1,$", MR_Next}, 626a8c51b3fSopenharmony_ci {"\"aggregate_name\": \"stddev\",$", MR_Next}, 627a8c51b3fSopenharmony_ci {"\"aggregate_unit\": \"time\",$", MR_Next}, 628a8c51b3fSopenharmony_ci {"\"iterations\": 4,$", MR_Next}}); 629a8c51b3fSopenharmony_ciADD_CASES(TC_CSVOut, {{"^\"BM_Repeat/repeats:4\",%csv_report$"}, 630a8c51b3fSopenharmony_ci {"^\"BM_Repeat/repeats:4\",%csv_report$"}, 631a8c51b3fSopenharmony_ci {"^\"BM_Repeat/repeats:4\",%csv_report$"}, 632a8c51b3fSopenharmony_ci {"^\"BM_Repeat/repeats:4\",%csv_report$"}, 633a8c51b3fSopenharmony_ci {"^\"BM_Repeat/repeats:4_mean\",%csv_report$"}, 634a8c51b3fSopenharmony_ci {"^\"BM_Repeat/repeats:4_median\",%csv_report$"}, 635a8c51b3fSopenharmony_ci {"^\"BM_Repeat/repeats:4_stddev\",%csv_report$"}}); 636a8c51b3fSopenharmony_ci 637a8c51b3fSopenharmony_ci// Test that a non-repeated test still prints non-aggregate results even when 638a8c51b3fSopenharmony_ci// only-aggregate reports have been requested 639a8c51b3fSopenharmony_civoid BM_RepeatOnce(benchmark::State& state) { 640a8c51b3fSopenharmony_ci for (auto _ : state) { 641a8c51b3fSopenharmony_ci } 642a8c51b3fSopenharmony_ci} 643a8c51b3fSopenharmony_ciBENCHMARK(BM_RepeatOnce)->Repetitions(1)->ReportAggregatesOnly(); 644a8c51b3fSopenharmony_ciADD_CASES(TC_ConsoleOut, {{"^BM_RepeatOnce/repeats:1 %console_report$"}}); 645a8c51b3fSopenharmony_ciADD_CASES(TC_JSONOut, {{"\"name\": \"BM_RepeatOnce/repeats:1\",$"}, 646a8c51b3fSopenharmony_ci {"\"family_index\": 18,$", MR_Next}, 647a8c51b3fSopenharmony_ci {"\"per_family_instance_index\": 0,$", MR_Next}, 648a8c51b3fSopenharmony_ci {"\"run_name\": \"BM_RepeatOnce/repeats:1\",$", MR_Next}, 649a8c51b3fSopenharmony_ci {"\"run_type\": \"iteration\",$", MR_Next}, 650a8c51b3fSopenharmony_ci {"\"repetitions\": 1,$", MR_Next}, 651a8c51b3fSopenharmony_ci {"\"repetition_index\": 0,$", MR_Next}, 652a8c51b3fSopenharmony_ci {"\"threads\": 1,$", MR_Next}}); 653a8c51b3fSopenharmony_ciADD_CASES(TC_CSVOut, {{"^\"BM_RepeatOnce/repeats:1\",%csv_report$"}}); 654a8c51b3fSopenharmony_ci 655a8c51b3fSopenharmony_ci// Test that non-aggregate data is not reported 656a8c51b3fSopenharmony_civoid BM_SummaryRepeat(benchmark::State& state) { 657a8c51b3fSopenharmony_ci for (auto _ : state) { 658a8c51b3fSopenharmony_ci } 659a8c51b3fSopenharmony_ci} 660a8c51b3fSopenharmony_ciBENCHMARK(BM_SummaryRepeat)->Repetitions(3)->ReportAggregatesOnly(); 661a8c51b3fSopenharmony_ciADD_CASES( 662a8c51b3fSopenharmony_ci TC_ConsoleOut, 663a8c51b3fSopenharmony_ci {{".*BM_SummaryRepeat/repeats:3 ", MR_Not}, 664a8c51b3fSopenharmony_ci {"^BM_SummaryRepeat/repeats:3_mean %console_time_only_report [ ]*3$"}, 665a8c51b3fSopenharmony_ci {"^BM_SummaryRepeat/repeats:3_median %console_time_only_report [ ]*3$"}, 666a8c51b3fSopenharmony_ci {"^BM_SummaryRepeat/repeats:3_stddev %console_time_only_report [ ]*3$"}}); 667a8c51b3fSopenharmony_ciADD_CASES(TC_JSONOut, 668a8c51b3fSopenharmony_ci {{".*BM_SummaryRepeat/repeats:3 ", MR_Not}, 669a8c51b3fSopenharmony_ci {"\"name\": \"BM_SummaryRepeat/repeats:3_mean\",$"}, 670a8c51b3fSopenharmony_ci {"\"family_index\": 19,$", MR_Next}, 671a8c51b3fSopenharmony_ci {"\"per_family_instance_index\": 0,$", MR_Next}, 672a8c51b3fSopenharmony_ci {"\"run_name\": \"BM_SummaryRepeat/repeats:3\",$", MR_Next}, 673a8c51b3fSopenharmony_ci {"\"run_type\": \"aggregate\",$", MR_Next}, 674a8c51b3fSopenharmony_ci {"\"repetitions\": 3,$", MR_Next}, 675a8c51b3fSopenharmony_ci {"\"threads\": 1,$", MR_Next}, 676a8c51b3fSopenharmony_ci {"\"aggregate_name\": \"mean\",$", MR_Next}, 677a8c51b3fSopenharmony_ci {"\"aggregate_unit\": \"time\",$", MR_Next}, 678a8c51b3fSopenharmony_ci {"\"iterations\": 3,$", MR_Next}, 679a8c51b3fSopenharmony_ci {"\"name\": \"BM_SummaryRepeat/repeats:3_median\",$"}, 680a8c51b3fSopenharmony_ci {"\"family_index\": 19,$", MR_Next}, 681a8c51b3fSopenharmony_ci {"\"per_family_instance_index\": 0,$", MR_Next}, 682a8c51b3fSopenharmony_ci {"\"run_name\": \"BM_SummaryRepeat/repeats:3\",$", MR_Next}, 683a8c51b3fSopenharmony_ci {"\"run_type\": \"aggregate\",$", MR_Next}, 684a8c51b3fSopenharmony_ci {"\"repetitions\": 3,$", MR_Next}, 685a8c51b3fSopenharmony_ci {"\"threads\": 1,$", MR_Next}, 686a8c51b3fSopenharmony_ci {"\"aggregate_name\": \"median\",$", MR_Next}, 687a8c51b3fSopenharmony_ci {"\"aggregate_unit\": \"time\",$", MR_Next}, 688a8c51b3fSopenharmony_ci {"\"iterations\": 3,$", MR_Next}, 689a8c51b3fSopenharmony_ci {"\"name\": \"BM_SummaryRepeat/repeats:3_stddev\",$"}, 690a8c51b3fSopenharmony_ci {"\"family_index\": 19,$", MR_Next}, 691a8c51b3fSopenharmony_ci {"\"per_family_instance_index\": 0,$", MR_Next}, 692a8c51b3fSopenharmony_ci {"\"run_name\": \"BM_SummaryRepeat/repeats:3\",$", MR_Next}, 693a8c51b3fSopenharmony_ci {"\"run_type\": \"aggregate\",$", MR_Next}, 694a8c51b3fSopenharmony_ci {"\"repetitions\": 3,$", MR_Next}, 695a8c51b3fSopenharmony_ci {"\"threads\": 1,$", MR_Next}, 696a8c51b3fSopenharmony_ci {"\"aggregate_name\": \"stddev\",$", MR_Next}, 697a8c51b3fSopenharmony_ci {"\"aggregate_unit\": \"time\",$", MR_Next}, 698a8c51b3fSopenharmony_ci {"\"iterations\": 3,$", MR_Next}}); 699a8c51b3fSopenharmony_ciADD_CASES(TC_CSVOut, {{".*BM_SummaryRepeat/repeats:3 ", MR_Not}, 700a8c51b3fSopenharmony_ci {"^\"BM_SummaryRepeat/repeats:3_mean\",%csv_report$"}, 701a8c51b3fSopenharmony_ci {"^\"BM_SummaryRepeat/repeats:3_median\",%csv_report$"}, 702a8c51b3fSopenharmony_ci {"^\"BM_SummaryRepeat/repeats:3_stddev\",%csv_report$"}}); 703a8c51b3fSopenharmony_ci 704a8c51b3fSopenharmony_ci// Test that non-aggregate data is not displayed. 705a8c51b3fSopenharmony_ci// NOTE: this test is kinda bad. we are only testing the display output. 706a8c51b3fSopenharmony_ci// But we don't check that the file output still contains everything... 707a8c51b3fSopenharmony_civoid BM_SummaryDisplay(benchmark::State& state) { 708a8c51b3fSopenharmony_ci for (auto _ : state) { 709a8c51b3fSopenharmony_ci } 710a8c51b3fSopenharmony_ci} 711a8c51b3fSopenharmony_ciBENCHMARK(BM_SummaryDisplay)->Repetitions(2)->DisplayAggregatesOnly(); 712a8c51b3fSopenharmony_ciADD_CASES( 713a8c51b3fSopenharmony_ci TC_ConsoleOut, 714a8c51b3fSopenharmony_ci {{".*BM_SummaryDisplay/repeats:2 ", MR_Not}, 715a8c51b3fSopenharmony_ci {"^BM_SummaryDisplay/repeats:2_mean %console_time_only_report [ ]*2$"}, 716a8c51b3fSopenharmony_ci {"^BM_SummaryDisplay/repeats:2_median %console_time_only_report [ ]*2$"}, 717a8c51b3fSopenharmony_ci {"^BM_SummaryDisplay/repeats:2_stddev %console_time_only_report [ ]*2$"}}); 718a8c51b3fSopenharmony_ciADD_CASES(TC_JSONOut, 719a8c51b3fSopenharmony_ci {{".*BM_SummaryDisplay/repeats:2 ", MR_Not}, 720a8c51b3fSopenharmony_ci {"\"name\": \"BM_SummaryDisplay/repeats:2_mean\",$"}, 721a8c51b3fSopenharmony_ci {"\"family_index\": 20,$", MR_Next}, 722a8c51b3fSopenharmony_ci {"\"per_family_instance_index\": 0,$", MR_Next}, 723a8c51b3fSopenharmony_ci {"\"run_name\": \"BM_SummaryDisplay/repeats:2\",$", MR_Next}, 724a8c51b3fSopenharmony_ci {"\"run_type\": \"aggregate\",$", MR_Next}, 725a8c51b3fSopenharmony_ci {"\"repetitions\": 2,$", MR_Next}, 726a8c51b3fSopenharmony_ci {"\"threads\": 1,$", MR_Next}, 727a8c51b3fSopenharmony_ci {"\"aggregate_name\": \"mean\",$", MR_Next}, 728a8c51b3fSopenharmony_ci {"\"aggregate_unit\": \"time\",$", MR_Next}, 729a8c51b3fSopenharmony_ci {"\"iterations\": 2,$", MR_Next}, 730a8c51b3fSopenharmony_ci {"\"name\": \"BM_SummaryDisplay/repeats:2_median\",$"}, 731a8c51b3fSopenharmony_ci {"\"family_index\": 20,$", MR_Next}, 732a8c51b3fSopenharmony_ci {"\"per_family_instance_index\": 0,$", MR_Next}, 733a8c51b3fSopenharmony_ci {"\"run_name\": \"BM_SummaryDisplay/repeats:2\",$", MR_Next}, 734a8c51b3fSopenharmony_ci {"\"run_type\": \"aggregate\",$", MR_Next}, 735a8c51b3fSopenharmony_ci {"\"repetitions\": 2,$", MR_Next}, 736a8c51b3fSopenharmony_ci {"\"threads\": 1,$", MR_Next}, 737a8c51b3fSopenharmony_ci {"\"aggregate_name\": \"median\",$", MR_Next}, 738a8c51b3fSopenharmony_ci {"\"aggregate_unit\": \"time\",$", MR_Next}, 739a8c51b3fSopenharmony_ci {"\"iterations\": 2,$", MR_Next}, 740a8c51b3fSopenharmony_ci {"\"name\": \"BM_SummaryDisplay/repeats:2_stddev\",$"}, 741a8c51b3fSopenharmony_ci {"\"family_index\": 20,$", MR_Next}, 742a8c51b3fSopenharmony_ci {"\"per_family_instance_index\": 0,$", MR_Next}, 743a8c51b3fSopenharmony_ci {"\"run_name\": \"BM_SummaryDisplay/repeats:2\",$", MR_Next}, 744a8c51b3fSopenharmony_ci {"\"run_type\": \"aggregate\",$", MR_Next}, 745a8c51b3fSopenharmony_ci {"\"repetitions\": 2,$", MR_Next}, 746a8c51b3fSopenharmony_ci {"\"threads\": 1,$", MR_Next}, 747a8c51b3fSopenharmony_ci {"\"aggregate_name\": \"stddev\",$", MR_Next}, 748a8c51b3fSopenharmony_ci {"\"aggregate_unit\": \"time\",$", MR_Next}, 749a8c51b3fSopenharmony_ci {"\"iterations\": 2,$", MR_Next}}); 750a8c51b3fSopenharmony_ciADD_CASES(TC_CSVOut, 751a8c51b3fSopenharmony_ci {{".*BM_SummaryDisplay/repeats:2 ", MR_Not}, 752a8c51b3fSopenharmony_ci {"^\"BM_SummaryDisplay/repeats:2_mean\",%csv_report$"}, 753a8c51b3fSopenharmony_ci {"^\"BM_SummaryDisplay/repeats:2_median\",%csv_report$"}, 754a8c51b3fSopenharmony_ci {"^\"BM_SummaryDisplay/repeats:2_stddev\",%csv_report$"}}); 755a8c51b3fSopenharmony_ci 756a8c51b3fSopenharmony_ci// Test repeats with custom time unit. 757a8c51b3fSopenharmony_civoid BM_RepeatTimeUnit(benchmark::State& state) { 758a8c51b3fSopenharmony_ci for (auto _ : state) { 759a8c51b3fSopenharmony_ci } 760a8c51b3fSopenharmony_ci} 761a8c51b3fSopenharmony_ciBENCHMARK(BM_RepeatTimeUnit) 762a8c51b3fSopenharmony_ci ->Repetitions(3) 763a8c51b3fSopenharmony_ci ->ReportAggregatesOnly() 764a8c51b3fSopenharmony_ci ->Unit(benchmark::kMicrosecond); 765a8c51b3fSopenharmony_ciADD_CASES( 766a8c51b3fSopenharmony_ci TC_ConsoleOut, 767a8c51b3fSopenharmony_ci {{".*BM_RepeatTimeUnit/repeats:3 ", MR_Not}, 768a8c51b3fSopenharmony_ci {"^BM_RepeatTimeUnit/repeats:3_mean %console_us_time_only_report [ ]*3$"}, 769a8c51b3fSopenharmony_ci {"^BM_RepeatTimeUnit/repeats:3_median %console_us_time_only_report [ " 770a8c51b3fSopenharmony_ci "]*3$"}, 771a8c51b3fSopenharmony_ci {"^BM_RepeatTimeUnit/repeats:3_stddev %console_us_time_only_report [ " 772a8c51b3fSopenharmony_ci "]*3$"}}); 773a8c51b3fSopenharmony_ciADD_CASES(TC_JSONOut, 774a8c51b3fSopenharmony_ci {{".*BM_RepeatTimeUnit/repeats:3 ", MR_Not}, 775a8c51b3fSopenharmony_ci {"\"name\": \"BM_RepeatTimeUnit/repeats:3_mean\",$"}, 776a8c51b3fSopenharmony_ci {"\"family_index\": 21,$", MR_Next}, 777a8c51b3fSopenharmony_ci {"\"per_family_instance_index\": 0,$", MR_Next}, 778a8c51b3fSopenharmony_ci {"\"run_name\": \"BM_RepeatTimeUnit/repeats:3\",$", MR_Next}, 779a8c51b3fSopenharmony_ci {"\"run_type\": \"aggregate\",$", MR_Next}, 780a8c51b3fSopenharmony_ci {"\"repetitions\": 3,$", MR_Next}, 781a8c51b3fSopenharmony_ci {"\"threads\": 1,$", MR_Next}, 782a8c51b3fSopenharmony_ci {"\"aggregate_name\": \"mean\",$", MR_Next}, 783a8c51b3fSopenharmony_ci {"\"aggregate_unit\": \"time\",$", MR_Next}, 784a8c51b3fSopenharmony_ci {"\"iterations\": 3,$", MR_Next}, 785a8c51b3fSopenharmony_ci {"\"time_unit\": \"us\",?$"}, 786a8c51b3fSopenharmony_ci {"\"name\": \"BM_RepeatTimeUnit/repeats:3_median\",$"}, 787a8c51b3fSopenharmony_ci {"\"family_index\": 21,$", MR_Next}, 788a8c51b3fSopenharmony_ci {"\"per_family_instance_index\": 0,$", MR_Next}, 789a8c51b3fSopenharmony_ci {"\"run_name\": \"BM_RepeatTimeUnit/repeats:3\",$", MR_Next}, 790a8c51b3fSopenharmony_ci {"\"run_type\": \"aggregate\",$", MR_Next}, 791a8c51b3fSopenharmony_ci {"\"repetitions\": 3,$", MR_Next}, 792a8c51b3fSopenharmony_ci {"\"threads\": 1,$", MR_Next}, 793a8c51b3fSopenharmony_ci {"\"aggregate_name\": \"median\",$", MR_Next}, 794a8c51b3fSopenharmony_ci {"\"aggregate_unit\": \"time\",$", MR_Next}, 795a8c51b3fSopenharmony_ci {"\"iterations\": 3,$", MR_Next}, 796a8c51b3fSopenharmony_ci {"\"time_unit\": \"us\",?$"}, 797a8c51b3fSopenharmony_ci {"\"name\": \"BM_RepeatTimeUnit/repeats:3_stddev\",$"}, 798a8c51b3fSopenharmony_ci {"\"family_index\": 21,$", MR_Next}, 799a8c51b3fSopenharmony_ci {"\"per_family_instance_index\": 0,$", MR_Next}, 800a8c51b3fSopenharmony_ci {"\"run_name\": \"BM_RepeatTimeUnit/repeats:3\",$", MR_Next}, 801a8c51b3fSopenharmony_ci {"\"run_type\": \"aggregate\",$", MR_Next}, 802a8c51b3fSopenharmony_ci {"\"repetitions\": 3,$", MR_Next}, 803a8c51b3fSopenharmony_ci {"\"threads\": 1,$", MR_Next}, 804a8c51b3fSopenharmony_ci {"\"aggregate_name\": \"stddev\",$", MR_Next}, 805a8c51b3fSopenharmony_ci {"\"aggregate_unit\": \"time\",$", MR_Next}, 806a8c51b3fSopenharmony_ci {"\"iterations\": 3,$", MR_Next}, 807a8c51b3fSopenharmony_ci {"\"time_unit\": \"us\",?$"}}); 808a8c51b3fSopenharmony_ciADD_CASES(TC_CSVOut, 809a8c51b3fSopenharmony_ci {{".*BM_RepeatTimeUnit/repeats:3 ", MR_Not}, 810a8c51b3fSopenharmony_ci {"^\"BM_RepeatTimeUnit/repeats:3_mean\",%csv_us_report$"}, 811a8c51b3fSopenharmony_ci {"^\"BM_RepeatTimeUnit/repeats:3_median\",%csv_us_report$"}, 812a8c51b3fSopenharmony_ci {"^\"BM_RepeatTimeUnit/repeats:3_stddev\",%csv_us_report$"}}); 813a8c51b3fSopenharmony_ci 814a8c51b3fSopenharmony_ci// ========================================================================= // 815a8c51b3fSopenharmony_ci// -------------------- Testing user-provided statistics ------------------- // 816a8c51b3fSopenharmony_ci// ========================================================================= // 817a8c51b3fSopenharmony_ci 818a8c51b3fSopenharmony_ciconst auto UserStatistics = [](const std::vector<double>& v) { 819a8c51b3fSopenharmony_ci return v.back(); 820a8c51b3fSopenharmony_ci}; 821a8c51b3fSopenharmony_civoid BM_UserStats(benchmark::State& state) { 822a8c51b3fSopenharmony_ci for (auto _ : state) { 823a8c51b3fSopenharmony_ci state.SetIterationTime(150 / 10e8); 824a8c51b3fSopenharmony_ci } 825a8c51b3fSopenharmony_ci} 826a8c51b3fSopenharmony_ci// clang-format off 827a8c51b3fSopenharmony_ciBENCHMARK(BM_UserStats) 828a8c51b3fSopenharmony_ci ->Repetitions(3) 829a8c51b3fSopenharmony_ci ->Iterations(5) 830a8c51b3fSopenharmony_ci ->UseManualTime() 831a8c51b3fSopenharmony_ci ->ComputeStatistics("", UserStatistics); 832a8c51b3fSopenharmony_ci// clang-format on 833a8c51b3fSopenharmony_ci 834a8c51b3fSopenharmony_ci// check that user-provided stats is calculated, and is after the default-ones 835a8c51b3fSopenharmony_ci// empty string as name is intentional, it would sort before anything else 836a8c51b3fSopenharmony_ciADD_CASES(TC_ConsoleOut, {{"^BM_UserStats/iterations:5/repeats:3/manual_time [ " 837a8c51b3fSopenharmony_ci "]* 150 ns %time [ ]*5$"}, 838a8c51b3fSopenharmony_ci {"^BM_UserStats/iterations:5/repeats:3/manual_time [ " 839a8c51b3fSopenharmony_ci "]* 150 ns %time [ ]*5$"}, 840a8c51b3fSopenharmony_ci {"^BM_UserStats/iterations:5/repeats:3/manual_time [ " 841a8c51b3fSopenharmony_ci "]* 150 ns %time [ ]*5$"}, 842a8c51b3fSopenharmony_ci {"^BM_UserStats/iterations:5/repeats:3/" 843a8c51b3fSopenharmony_ci "manual_time_mean [ ]* 150 ns %time [ ]*3$"}, 844a8c51b3fSopenharmony_ci {"^BM_UserStats/iterations:5/repeats:3/" 845a8c51b3fSopenharmony_ci "manual_time_median [ ]* 150 ns %time [ ]*3$"}, 846a8c51b3fSopenharmony_ci {"^BM_UserStats/iterations:5/repeats:3/" 847a8c51b3fSopenharmony_ci "manual_time_stddev [ ]* 0.000 ns %time [ ]*3$"}, 848a8c51b3fSopenharmony_ci {"^BM_UserStats/iterations:5/repeats:3/manual_time_ " 849a8c51b3fSopenharmony_ci "[ ]* 150 ns %time [ ]*3$"}}); 850a8c51b3fSopenharmony_ciADD_CASES( 851a8c51b3fSopenharmony_ci TC_JSONOut, 852a8c51b3fSopenharmony_ci {{"\"name\": \"BM_UserStats/iterations:5/repeats:3/manual_time\",$"}, 853a8c51b3fSopenharmony_ci {"\"family_index\": 22,$", MR_Next}, 854a8c51b3fSopenharmony_ci {"\"per_family_instance_index\": 0,$", MR_Next}, 855a8c51b3fSopenharmony_ci {"\"run_name\": \"BM_UserStats/iterations:5/repeats:3/manual_time\",$", 856a8c51b3fSopenharmony_ci MR_Next}, 857a8c51b3fSopenharmony_ci {"\"run_type\": \"iteration\",$", MR_Next}, 858a8c51b3fSopenharmony_ci {"\"repetitions\": 3,$", MR_Next}, 859a8c51b3fSopenharmony_ci {"\"repetition_index\": 0,$", MR_Next}, 860a8c51b3fSopenharmony_ci {"\"threads\": 1,$", MR_Next}, 861a8c51b3fSopenharmony_ci {"\"iterations\": 5,$", MR_Next}, 862a8c51b3fSopenharmony_ci {"\"real_time\": 1\\.5(0)*e\\+(0)*2,$", MR_Next}, 863a8c51b3fSopenharmony_ci {"\"name\": \"BM_UserStats/iterations:5/repeats:3/manual_time\",$"}, 864a8c51b3fSopenharmony_ci {"\"family_index\": 22,$", MR_Next}, 865a8c51b3fSopenharmony_ci {"\"per_family_instance_index\": 0,$", MR_Next}, 866a8c51b3fSopenharmony_ci {"\"run_name\": \"BM_UserStats/iterations:5/repeats:3/manual_time\",$", 867a8c51b3fSopenharmony_ci MR_Next}, 868a8c51b3fSopenharmony_ci {"\"run_type\": \"iteration\",$", MR_Next}, 869a8c51b3fSopenharmony_ci {"\"repetitions\": 3,$", MR_Next}, 870a8c51b3fSopenharmony_ci {"\"repetition_index\": 1,$", MR_Next}, 871a8c51b3fSopenharmony_ci {"\"threads\": 1,$", MR_Next}, 872a8c51b3fSopenharmony_ci {"\"iterations\": 5,$", MR_Next}, 873a8c51b3fSopenharmony_ci {"\"real_time\": 1\\.5(0)*e\\+(0)*2,$", MR_Next}, 874a8c51b3fSopenharmony_ci {"\"name\": \"BM_UserStats/iterations:5/repeats:3/manual_time\",$"}, 875a8c51b3fSopenharmony_ci {"\"family_index\": 22,$", MR_Next}, 876a8c51b3fSopenharmony_ci {"\"per_family_instance_index\": 0,$", MR_Next}, 877a8c51b3fSopenharmony_ci {"\"run_name\": \"BM_UserStats/iterations:5/repeats:3/manual_time\",$", 878a8c51b3fSopenharmony_ci MR_Next}, 879a8c51b3fSopenharmony_ci {"\"run_type\": \"iteration\",$", MR_Next}, 880a8c51b3fSopenharmony_ci {"\"repetitions\": 3,$", MR_Next}, 881a8c51b3fSopenharmony_ci {"\"repetition_index\": 2,$", MR_Next}, 882a8c51b3fSopenharmony_ci {"\"threads\": 1,$", MR_Next}, 883a8c51b3fSopenharmony_ci {"\"iterations\": 5,$", MR_Next}, 884a8c51b3fSopenharmony_ci {"\"real_time\": 1\\.5(0)*e\\+(0)*2,$", MR_Next}, 885a8c51b3fSopenharmony_ci {"\"name\": \"BM_UserStats/iterations:5/repeats:3/manual_time_mean\",$"}, 886a8c51b3fSopenharmony_ci {"\"family_index\": 22,$", MR_Next}, 887a8c51b3fSopenharmony_ci {"\"per_family_instance_index\": 0,$", MR_Next}, 888a8c51b3fSopenharmony_ci {"\"run_name\": \"BM_UserStats/iterations:5/repeats:3/manual_time\",$", 889a8c51b3fSopenharmony_ci MR_Next}, 890a8c51b3fSopenharmony_ci {"\"run_type\": \"aggregate\",$", MR_Next}, 891a8c51b3fSopenharmony_ci {"\"repetitions\": 3,$", MR_Next}, 892a8c51b3fSopenharmony_ci {"\"threads\": 1,$", MR_Next}, 893a8c51b3fSopenharmony_ci {"\"aggregate_name\": \"mean\",$", MR_Next}, 894a8c51b3fSopenharmony_ci {"\"aggregate_unit\": \"time\",$", MR_Next}, 895a8c51b3fSopenharmony_ci {"\"iterations\": 3,$", MR_Next}, 896a8c51b3fSopenharmony_ci {"\"real_time\": 1\\.5(0)*e\\+(0)*2,$", MR_Next}, 897a8c51b3fSopenharmony_ci {"\"name\": \"BM_UserStats/iterations:5/repeats:3/manual_time_median\",$"}, 898a8c51b3fSopenharmony_ci {"\"family_index\": 22,$", MR_Next}, 899a8c51b3fSopenharmony_ci {"\"per_family_instance_index\": 0,$", MR_Next}, 900a8c51b3fSopenharmony_ci {"\"run_name\": \"BM_UserStats/iterations:5/repeats:3/manual_time\",$", 901a8c51b3fSopenharmony_ci MR_Next}, 902a8c51b3fSopenharmony_ci {"\"run_type\": \"aggregate\",$", MR_Next}, 903a8c51b3fSopenharmony_ci {"\"repetitions\": 3,$", MR_Next}, 904a8c51b3fSopenharmony_ci {"\"threads\": 1,$", MR_Next}, 905a8c51b3fSopenharmony_ci {"\"aggregate_name\": \"median\",$", MR_Next}, 906a8c51b3fSopenharmony_ci {"\"aggregate_unit\": \"time\",$", MR_Next}, 907a8c51b3fSopenharmony_ci {"\"iterations\": 3,$", MR_Next}, 908a8c51b3fSopenharmony_ci {"\"real_time\": 1\\.5(0)*e\\+(0)*2,$", MR_Next}, 909a8c51b3fSopenharmony_ci {"\"name\": \"BM_UserStats/iterations:5/repeats:3/manual_time_stddev\",$"}, 910a8c51b3fSopenharmony_ci {"\"family_index\": 22,$", MR_Next}, 911a8c51b3fSopenharmony_ci {"\"per_family_instance_index\": 0,$", MR_Next}, 912a8c51b3fSopenharmony_ci {"\"run_name\": \"BM_UserStats/iterations:5/repeats:3/manual_time\",$", 913a8c51b3fSopenharmony_ci MR_Next}, 914a8c51b3fSopenharmony_ci {"\"run_type\": \"aggregate\",$", MR_Next}, 915a8c51b3fSopenharmony_ci {"\"repetitions\": 3,$", MR_Next}, 916a8c51b3fSopenharmony_ci {"\"threads\": 1,$", MR_Next}, 917a8c51b3fSopenharmony_ci {"\"aggregate_name\": \"stddev\",$", MR_Next}, 918a8c51b3fSopenharmony_ci {"\"aggregate_unit\": \"time\",$", MR_Next}, 919a8c51b3fSopenharmony_ci {"\"iterations\": 3,$", MR_Next}, 920a8c51b3fSopenharmony_ci {"\"real_time\": %float,$", MR_Next}, 921a8c51b3fSopenharmony_ci {"\"name\": \"BM_UserStats/iterations:5/repeats:3/manual_time_\",$"}, 922a8c51b3fSopenharmony_ci {"\"family_index\": 22,$", MR_Next}, 923a8c51b3fSopenharmony_ci {"\"per_family_instance_index\": 0,$", MR_Next}, 924a8c51b3fSopenharmony_ci {"\"run_name\": \"BM_UserStats/iterations:5/repeats:3/manual_time\",$", 925a8c51b3fSopenharmony_ci MR_Next}, 926a8c51b3fSopenharmony_ci {"\"run_type\": \"aggregate\",$", MR_Next}, 927a8c51b3fSopenharmony_ci {"\"repetitions\": 3,$", MR_Next}, 928a8c51b3fSopenharmony_ci {"\"threads\": 1,$", MR_Next}, 929a8c51b3fSopenharmony_ci {"\"aggregate_name\": \"\",$", MR_Next}, 930a8c51b3fSopenharmony_ci {"\"aggregate_unit\": \"time\",$", MR_Next}, 931a8c51b3fSopenharmony_ci {"\"iterations\": 3,$", MR_Next}, 932a8c51b3fSopenharmony_ci {"\"real_time\": 1\\.5(0)*e\\+(0)*2,$", MR_Next}}); 933a8c51b3fSopenharmony_ciADD_CASES( 934a8c51b3fSopenharmony_ci TC_CSVOut, 935a8c51b3fSopenharmony_ci {{"^\"BM_UserStats/iterations:5/repeats:3/manual_time\",%csv_report$"}, 936a8c51b3fSopenharmony_ci {"^\"BM_UserStats/iterations:5/repeats:3/manual_time\",%csv_report$"}, 937a8c51b3fSopenharmony_ci {"^\"BM_UserStats/iterations:5/repeats:3/manual_time\",%csv_report$"}, 938a8c51b3fSopenharmony_ci {"^\"BM_UserStats/iterations:5/repeats:3/manual_time_mean\",%csv_report$"}, 939a8c51b3fSopenharmony_ci {"^\"BM_UserStats/iterations:5/repeats:3/" 940a8c51b3fSopenharmony_ci "manual_time_median\",%csv_report$"}, 941a8c51b3fSopenharmony_ci {"^\"BM_UserStats/iterations:5/repeats:3/" 942a8c51b3fSopenharmony_ci "manual_time_stddev\",%csv_report$"}, 943a8c51b3fSopenharmony_ci {"^\"BM_UserStats/iterations:5/repeats:3/manual_time_\",%csv_report$"}}); 944a8c51b3fSopenharmony_ci 945a8c51b3fSopenharmony_ci// ========================================================================= // 946a8c51b3fSopenharmony_ci// ------------- Testing relative standard deviation statistics ------------ // 947a8c51b3fSopenharmony_ci// ========================================================================= // 948a8c51b3fSopenharmony_ci 949a8c51b3fSopenharmony_ciconst auto UserPercentStatistics = [](const std::vector<double>&) { 950a8c51b3fSopenharmony_ci return 1. / 100.; 951a8c51b3fSopenharmony_ci}; 952a8c51b3fSopenharmony_civoid BM_UserPercentStats(benchmark::State& state) { 953a8c51b3fSopenharmony_ci for (auto _ : state) { 954a8c51b3fSopenharmony_ci state.SetIterationTime(150 / 10e8); 955a8c51b3fSopenharmony_ci } 956a8c51b3fSopenharmony_ci} 957a8c51b3fSopenharmony_ci// clang-format off 958a8c51b3fSopenharmony_ciBENCHMARK(BM_UserPercentStats) 959a8c51b3fSopenharmony_ci ->Repetitions(3) 960a8c51b3fSopenharmony_ci ->Iterations(5) 961a8c51b3fSopenharmony_ci ->UseManualTime() 962a8c51b3fSopenharmony_ci ->Unit(benchmark::TimeUnit::kNanosecond) 963a8c51b3fSopenharmony_ci ->ComputeStatistics("", UserPercentStatistics, benchmark::StatisticUnit::kPercentage); 964a8c51b3fSopenharmony_ci// clang-format on 965a8c51b3fSopenharmony_ci 966a8c51b3fSopenharmony_ci// check that UserPercent-provided stats is calculated, and is after the 967a8c51b3fSopenharmony_ci// default-ones empty string as name is intentional, it would sort before 968a8c51b3fSopenharmony_ci// anything else 969a8c51b3fSopenharmony_ciADD_CASES(TC_ConsoleOut, 970a8c51b3fSopenharmony_ci {{"^BM_UserPercentStats/iterations:5/repeats:3/manual_time [ " 971a8c51b3fSopenharmony_ci "]* 150 ns %time [ ]*5$"}, 972a8c51b3fSopenharmony_ci {"^BM_UserPercentStats/iterations:5/repeats:3/manual_time [ " 973a8c51b3fSopenharmony_ci "]* 150 ns %time [ ]*5$"}, 974a8c51b3fSopenharmony_ci {"^BM_UserPercentStats/iterations:5/repeats:3/manual_time [ " 975a8c51b3fSopenharmony_ci "]* 150 ns %time [ ]*5$"}, 976a8c51b3fSopenharmony_ci {"^BM_UserPercentStats/iterations:5/repeats:3/" 977a8c51b3fSopenharmony_ci "manual_time_mean [ ]* 150 ns %time [ ]*3$"}, 978a8c51b3fSopenharmony_ci {"^BM_UserPercentStats/iterations:5/repeats:3/" 979a8c51b3fSopenharmony_ci "manual_time_median [ ]* 150 ns %time [ ]*3$"}, 980a8c51b3fSopenharmony_ci {"^BM_UserPercentStats/iterations:5/repeats:3/" 981a8c51b3fSopenharmony_ci "manual_time_stddev [ ]* 0.000 ns %time [ ]*3$"}, 982a8c51b3fSopenharmony_ci {"^BM_UserPercentStats/iterations:5/repeats:3/manual_time_ " 983a8c51b3fSopenharmony_ci "[ ]* 1.00 % [ ]* 1.00 %[ ]*3$"}}); 984a8c51b3fSopenharmony_ciADD_CASES( 985a8c51b3fSopenharmony_ci TC_JSONOut, 986a8c51b3fSopenharmony_ci {{"\"name\": \"BM_UserPercentStats/iterations:5/repeats:3/manual_time\",$"}, 987a8c51b3fSopenharmony_ci {"\"family_index\": 23,$", MR_Next}, 988a8c51b3fSopenharmony_ci {"\"per_family_instance_index\": 0,$", MR_Next}, 989a8c51b3fSopenharmony_ci {"\"run_name\": " 990a8c51b3fSopenharmony_ci "\"BM_UserPercentStats/iterations:5/repeats:3/manual_time\",$", 991a8c51b3fSopenharmony_ci MR_Next}, 992a8c51b3fSopenharmony_ci {"\"run_type\": \"iteration\",$", MR_Next}, 993a8c51b3fSopenharmony_ci {"\"repetitions\": 3,$", MR_Next}, 994a8c51b3fSopenharmony_ci {"\"repetition_index\": 0,$", MR_Next}, 995a8c51b3fSopenharmony_ci {"\"threads\": 1,$", MR_Next}, 996a8c51b3fSopenharmony_ci {"\"iterations\": 5,$", MR_Next}, 997a8c51b3fSopenharmony_ci {"\"real_time\": 1\\.5(0)*e\\+(0)*2,$", MR_Next}, 998a8c51b3fSopenharmony_ci {"\"name\": \"BM_UserPercentStats/iterations:5/repeats:3/manual_time\",$"}, 999a8c51b3fSopenharmony_ci {"\"family_index\": 23,$", MR_Next}, 1000a8c51b3fSopenharmony_ci {"\"per_family_instance_index\": 0,$", MR_Next}, 1001a8c51b3fSopenharmony_ci {"\"run_name\": " 1002a8c51b3fSopenharmony_ci "\"BM_UserPercentStats/iterations:5/repeats:3/manual_time\",$", 1003a8c51b3fSopenharmony_ci MR_Next}, 1004a8c51b3fSopenharmony_ci {"\"run_type\": \"iteration\",$", MR_Next}, 1005a8c51b3fSopenharmony_ci {"\"repetitions\": 3,$", MR_Next}, 1006a8c51b3fSopenharmony_ci {"\"repetition_index\": 1,$", MR_Next}, 1007a8c51b3fSopenharmony_ci {"\"threads\": 1,$", MR_Next}, 1008a8c51b3fSopenharmony_ci {"\"iterations\": 5,$", MR_Next}, 1009a8c51b3fSopenharmony_ci {"\"real_time\": 1\\.5(0)*e\\+(0)*2,$", MR_Next}, 1010a8c51b3fSopenharmony_ci {"\"name\": \"BM_UserPercentStats/iterations:5/repeats:3/manual_time\",$"}, 1011a8c51b3fSopenharmony_ci {"\"family_index\": 23,$", MR_Next}, 1012a8c51b3fSopenharmony_ci {"\"per_family_instance_index\": 0,$", MR_Next}, 1013a8c51b3fSopenharmony_ci {"\"run_name\": " 1014a8c51b3fSopenharmony_ci "\"BM_UserPercentStats/iterations:5/repeats:3/manual_time\",$", 1015a8c51b3fSopenharmony_ci MR_Next}, 1016a8c51b3fSopenharmony_ci {"\"run_type\": \"iteration\",$", MR_Next}, 1017a8c51b3fSopenharmony_ci {"\"repetitions\": 3,$", MR_Next}, 1018a8c51b3fSopenharmony_ci {"\"repetition_index\": 2,$", MR_Next}, 1019a8c51b3fSopenharmony_ci {"\"threads\": 1,$", MR_Next}, 1020a8c51b3fSopenharmony_ci {"\"iterations\": 5,$", MR_Next}, 1021a8c51b3fSopenharmony_ci {"\"real_time\": 1\\.5(0)*e\\+(0)*2,$", MR_Next}, 1022a8c51b3fSopenharmony_ci {"\"name\": " 1023a8c51b3fSopenharmony_ci "\"BM_UserPercentStats/iterations:5/repeats:3/manual_time_mean\",$"}, 1024a8c51b3fSopenharmony_ci {"\"family_index\": 23,$", MR_Next}, 1025a8c51b3fSopenharmony_ci {"\"per_family_instance_index\": 0,$", MR_Next}, 1026a8c51b3fSopenharmony_ci {"\"run_name\": " 1027a8c51b3fSopenharmony_ci "\"BM_UserPercentStats/iterations:5/repeats:3/manual_time\",$", 1028a8c51b3fSopenharmony_ci MR_Next}, 1029a8c51b3fSopenharmony_ci {"\"run_type\": \"aggregate\",$", MR_Next}, 1030a8c51b3fSopenharmony_ci {"\"repetitions\": 3,$", MR_Next}, 1031a8c51b3fSopenharmony_ci {"\"threads\": 1,$", MR_Next}, 1032a8c51b3fSopenharmony_ci {"\"aggregate_name\": \"mean\",$", MR_Next}, 1033a8c51b3fSopenharmony_ci {"\"aggregate_unit\": \"time\",$", MR_Next}, 1034a8c51b3fSopenharmony_ci {"\"iterations\": 3,$", MR_Next}, 1035a8c51b3fSopenharmony_ci {"\"real_time\": 1\\.5(0)*e\\+(0)*2,$", MR_Next}, 1036a8c51b3fSopenharmony_ci {"\"name\": " 1037a8c51b3fSopenharmony_ci "\"BM_UserPercentStats/iterations:5/repeats:3/manual_time_median\",$"}, 1038a8c51b3fSopenharmony_ci {"\"family_index\": 23,$", MR_Next}, 1039a8c51b3fSopenharmony_ci {"\"per_family_instance_index\": 0,$", MR_Next}, 1040a8c51b3fSopenharmony_ci {"\"run_name\": " 1041a8c51b3fSopenharmony_ci "\"BM_UserPercentStats/iterations:5/repeats:3/manual_time\",$", 1042a8c51b3fSopenharmony_ci MR_Next}, 1043a8c51b3fSopenharmony_ci {"\"run_type\": \"aggregate\",$", MR_Next}, 1044a8c51b3fSopenharmony_ci {"\"repetitions\": 3,$", MR_Next}, 1045a8c51b3fSopenharmony_ci {"\"threads\": 1,$", MR_Next}, 1046a8c51b3fSopenharmony_ci {"\"aggregate_name\": \"median\",$", MR_Next}, 1047a8c51b3fSopenharmony_ci {"\"aggregate_unit\": \"time\",$", MR_Next}, 1048a8c51b3fSopenharmony_ci {"\"iterations\": 3,$", MR_Next}, 1049a8c51b3fSopenharmony_ci {"\"real_time\": 1\\.5(0)*e\\+(0)*2,$", MR_Next}, 1050a8c51b3fSopenharmony_ci {"\"name\": " 1051a8c51b3fSopenharmony_ci "\"BM_UserPercentStats/iterations:5/repeats:3/manual_time_stddev\",$"}, 1052a8c51b3fSopenharmony_ci {"\"family_index\": 23,$", MR_Next}, 1053a8c51b3fSopenharmony_ci {"\"per_family_instance_index\": 0,$", MR_Next}, 1054a8c51b3fSopenharmony_ci {"\"run_name\": " 1055a8c51b3fSopenharmony_ci "\"BM_UserPercentStats/iterations:5/repeats:3/manual_time\",$", 1056a8c51b3fSopenharmony_ci MR_Next}, 1057a8c51b3fSopenharmony_ci {"\"run_type\": \"aggregate\",$", MR_Next}, 1058a8c51b3fSopenharmony_ci {"\"repetitions\": 3,$", MR_Next}, 1059a8c51b3fSopenharmony_ci {"\"threads\": 1,$", MR_Next}, 1060a8c51b3fSopenharmony_ci {"\"aggregate_name\": \"stddev\",$", MR_Next}, 1061a8c51b3fSopenharmony_ci {"\"aggregate_unit\": \"time\",$", MR_Next}, 1062a8c51b3fSopenharmony_ci {"\"iterations\": 3,$", MR_Next}, 1063a8c51b3fSopenharmony_ci {"\"real_time\": %float,$", MR_Next}, 1064a8c51b3fSopenharmony_ci {"\"name\": " 1065a8c51b3fSopenharmony_ci "\"BM_UserPercentStats/iterations:5/repeats:3/manual_time_\",$"}, 1066a8c51b3fSopenharmony_ci {"\"family_index\": 23,$", MR_Next}, 1067a8c51b3fSopenharmony_ci {"\"per_family_instance_index\": 0,$", MR_Next}, 1068a8c51b3fSopenharmony_ci {"\"run_name\": " 1069a8c51b3fSopenharmony_ci "\"BM_UserPercentStats/iterations:5/repeats:3/manual_time\",$", 1070a8c51b3fSopenharmony_ci MR_Next}, 1071a8c51b3fSopenharmony_ci {"\"run_type\": \"aggregate\",$", MR_Next}, 1072a8c51b3fSopenharmony_ci {"\"repetitions\": 3,$", MR_Next}, 1073a8c51b3fSopenharmony_ci {"\"threads\": 1,$", MR_Next}, 1074a8c51b3fSopenharmony_ci {"\"aggregate_name\": \"\",$", MR_Next}, 1075a8c51b3fSopenharmony_ci {"\"aggregate_unit\": \"percentage\",$", MR_Next}, 1076a8c51b3fSopenharmony_ci {"\"iterations\": 3,$", MR_Next}, 1077a8c51b3fSopenharmony_ci {"\"real_time\": 1\\.(0)*e-(0)*2,$", MR_Next}}); 1078a8c51b3fSopenharmony_ciADD_CASES(TC_CSVOut, {{"^\"BM_UserPercentStats/iterations:5/repeats:3/" 1079a8c51b3fSopenharmony_ci "manual_time\",%csv_report$"}, 1080a8c51b3fSopenharmony_ci {"^\"BM_UserPercentStats/iterations:5/repeats:3/" 1081a8c51b3fSopenharmony_ci "manual_time\",%csv_report$"}, 1082a8c51b3fSopenharmony_ci {"^\"BM_UserPercentStats/iterations:5/repeats:3/" 1083a8c51b3fSopenharmony_ci "manual_time\",%csv_report$"}, 1084a8c51b3fSopenharmony_ci {"^\"BM_UserPercentStats/iterations:5/repeats:3/" 1085a8c51b3fSopenharmony_ci "manual_time_mean\",%csv_report$"}, 1086a8c51b3fSopenharmony_ci {"^\"BM_UserPercentStats/iterations:5/repeats:3/" 1087a8c51b3fSopenharmony_ci "manual_time_median\",%csv_report$"}, 1088a8c51b3fSopenharmony_ci {"^\"BM_UserPercentStats/iterations:5/repeats:3/" 1089a8c51b3fSopenharmony_ci "manual_time_stddev\",%csv_report$"}, 1090a8c51b3fSopenharmony_ci {"^\"BM_UserPercentStats/iterations:5/repeats:3/" 1091a8c51b3fSopenharmony_ci "manual_time_\",%csv_report$"}}); 1092a8c51b3fSopenharmony_ci 1093a8c51b3fSopenharmony_ci// ========================================================================= // 1094a8c51b3fSopenharmony_ci// ------------------------- Testing StrEscape JSON ------------------------ // 1095a8c51b3fSopenharmony_ci// ========================================================================= // 1096a8c51b3fSopenharmony_ci#if 0 // enable when csv testing code correctly handles multi-line fields 1097a8c51b3fSopenharmony_civoid BM_JSON_Format(benchmark::State& state) { 1098a8c51b3fSopenharmony_ci state.SkipWithError("val\b\f\n\r\t\\\"with\"es,capes"); 1099a8c51b3fSopenharmony_ci for (auto _ : state) { 1100a8c51b3fSopenharmony_ci } 1101a8c51b3fSopenharmony_ci} 1102a8c51b3fSopenharmony_ciBENCHMARK(BM_JSON_Format); 1103a8c51b3fSopenharmony_ciADD_CASES(TC_JSONOut, {{"\"name\": \"BM_JSON_Format\",$"}, 1104a8c51b3fSopenharmony_ci {"\"family_index\": 23,$", MR_Next}, 1105a8c51b3fSopenharmony_ci{"\"per_family_instance_index\": 0,$", MR_Next}, 1106a8c51b3fSopenharmony_ci {"\"run_name\": \"BM_JSON_Format\",$", MR_Next}, 1107a8c51b3fSopenharmony_ci {"\"run_type\": \"iteration\",$", MR_Next}, 1108a8c51b3fSopenharmony_ci {"\"repetitions\": 1,$", MR_Next}, 1109a8c51b3fSopenharmony_ci {"\"repetition_index\": 0,$", MR_Next}, 1110a8c51b3fSopenharmony_ci {"\"threads\": 1,$", MR_Next}, 1111a8c51b3fSopenharmony_ci {"\"error_occurred\": true,$", MR_Next}, 1112a8c51b3fSopenharmony_ci {R"("error_message": "val\\b\\f\\n\\r\\t\\\\\\"with\\"es,capes",$)", MR_Next}}); 1113a8c51b3fSopenharmony_ci#endif 1114a8c51b3fSopenharmony_ci// ========================================================================= // 1115a8c51b3fSopenharmony_ci// -------------------------- Testing CsvEscape ---------------------------- // 1116a8c51b3fSopenharmony_ci// ========================================================================= // 1117a8c51b3fSopenharmony_ci 1118a8c51b3fSopenharmony_civoid BM_CSV_Format(benchmark::State& state) { 1119a8c51b3fSopenharmony_ci state.SkipWithError("\"freedom\""); 1120a8c51b3fSopenharmony_ci for (auto _ : state) { 1121a8c51b3fSopenharmony_ci } 1122a8c51b3fSopenharmony_ci} 1123a8c51b3fSopenharmony_ciBENCHMARK(BM_CSV_Format); 1124a8c51b3fSopenharmony_ciADD_CASES(TC_CSVOut, {{"^\"BM_CSV_Format\",,,,,,,,true,\"\"\"freedom\"\"\"$"}}); 1125a8c51b3fSopenharmony_ci 1126a8c51b3fSopenharmony_ci// ========================================================================= // 1127a8c51b3fSopenharmony_ci// --------------------------- TEST CASES END ------------------------------ // 1128a8c51b3fSopenharmony_ci// ========================================================================= // 1129a8c51b3fSopenharmony_ci 1130a8c51b3fSopenharmony_ciint main(int argc, char* argv[]) { RunOutputTests(argc, argv); } 1131