brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.7 KiB · 6ad65e7 Raw
46 lines · plain
1 2#undef NDEBUG3#include <cstdio>4#include <string>5 6#include "benchmark/benchmark.h"7#include "output_test.h"8 9// Ok this test is super ugly. We want to check what happens with the file10// reporter in the presence of DisplayAggregatesOnly().11// We do not care about console output, the normal tests check that already.12 13void BM_SummaryRepeat(benchmark::State& state) {14  for (auto _ : state) {15  }16}17BENCHMARK(BM_SummaryRepeat)->Repetitions(3)->DisplayAggregatesOnly();18 19int main(int argc, char* argv[]) {20  const std::string output = GetFileReporterOutput(argc, argv);21 22  if (SubstrCnt(output, "\"name\": \"BM_SummaryRepeat/repeats:3") != 7 ||23      SubstrCnt(output, "\"name\": \"BM_SummaryRepeat/repeats:3\"") != 3 ||24      SubstrCnt(output, "\"name\": \"BM_SummaryRepeat/repeats:3_mean\"") != 1 ||25      SubstrCnt(output, "\"name\": \"BM_SummaryRepeat/repeats:3_median\"") !=26          1 ||27      SubstrCnt(output, "\"name\": \"BM_SummaryRepeat/repeats:3_stddev\"") !=28          1 ||29      SubstrCnt(output, "\"name\": \"BM_SummaryRepeat/repeats:3_cv\"") != 1) {30    std::cout << "Precondition mismatch. Expected to only find 8 "31                 "occurrences of \"BM_SummaryRepeat/repeats:3\" substring:\n"32                 "\"name\": \"BM_SummaryRepeat/repeats:3\", "33                 "\"name\": \"BM_SummaryRepeat/repeats:3\", "34                 "\"name\": \"BM_SummaryRepeat/repeats:3\", "35                 "\"name\": \"BM_SummaryRepeat/repeats:3_mean\", "36                 "\"name\": \"BM_SummaryRepeat/repeats:3_median\", "37                 "\"name\": \"BM_SummaryRepeat/repeats:3_stddev\", "38                 "\"name\": \"BM_SummaryRepeat/repeats:3_cv\"\nThe entire "39                 "output:\n";40    std::cout << output;41    return 1;42  }43 44  return 0;45}46