annotate libcxx/utils/google-benchmark/test/display_aggregates_only_test.cc @ 150:1d019706d866

LLVM10
author anatofuz
date Thu, 13 Feb 2020 15:10:13 +0900
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
150
anatofuz
parents:
diff changeset
1
anatofuz
parents:
diff changeset
2 #undef NDEBUG
anatofuz
parents:
diff changeset
3 #include <cstdio>
anatofuz
parents:
diff changeset
4 #include <string>
anatofuz
parents:
diff changeset
5
anatofuz
parents:
diff changeset
6 #include "benchmark/benchmark.h"
anatofuz
parents:
diff changeset
7 #include "output_test.h"
anatofuz
parents:
diff changeset
8
anatofuz
parents:
diff changeset
9 // Ok this test is super ugly. We want to check what happens with the file
anatofuz
parents:
diff changeset
10 // reporter in the presence of DisplayAggregatesOnly().
anatofuz
parents:
diff changeset
11 // We do not care about console output, the normal tests check that already.
anatofuz
parents:
diff changeset
12
anatofuz
parents:
diff changeset
13 void BM_SummaryRepeat(benchmark::State& state) {
anatofuz
parents:
diff changeset
14 for (auto _ : state) {
anatofuz
parents:
diff changeset
15 }
anatofuz
parents:
diff changeset
16 }
anatofuz
parents:
diff changeset
17 BENCHMARK(BM_SummaryRepeat)->Repetitions(3)->DisplayAggregatesOnly();
anatofuz
parents:
diff changeset
18
anatofuz
parents:
diff changeset
19 int main(int argc, char* argv[]) {
anatofuz
parents:
diff changeset
20 const std::string output = GetFileReporterOutput(argc, argv);
anatofuz
parents:
diff changeset
21
anatofuz
parents:
diff changeset
22 if (SubstrCnt(output, "\"name\": \"BM_SummaryRepeat/repeats:3") != 6 ||
anatofuz
parents:
diff changeset
23 SubstrCnt(output, "\"name\": \"BM_SummaryRepeat/repeats:3\"") != 3 ||
anatofuz
parents:
diff changeset
24 SubstrCnt(output, "\"name\": \"BM_SummaryRepeat/repeats:3_mean\"") != 1 ||
anatofuz
parents:
diff changeset
25 SubstrCnt(output, "\"name\": \"BM_SummaryRepeat/repeats:3_median\"") !=
anatofuz
parents:
diff changeset
26 1 ||
anatofuz
parents:
diff changeset
27 SubstrCnt(output, "\"name\": \"BM_SummaryRepeat/repeats:3_stddev\"") !=
anatofuz
parents:
diff changeset
28 1) {
anatofuz
parents:
diff changeset
29 std::cout << "Precondition mismatch. Expected to only find 6 "
anatofuz
parents:
diff changeset
30 "occurrences of \"BM_SummaryRepeat/repeats:3\" substring:\n"
anatofuz
parents:
diff changeset
31 "\"name\": \"BM_SummaryRepeat/repeats:3\", "
anatofuz
parents:
diff changeset
32 "\"name\": \"BM_SummaryRepeat/repeats:3\", "
anatofuz
parents:
diff changeset
33 "\"name\": \"BM_SummaryRepeat/repeats:3\", "
anatofuz
parents:
diff changeset
34 "\"name\": \"BM_SummaryRepeat/repeats:3_mean\", "
anatofuz
parents:
diff changeset
35 "\"name\": \"BM_SummaryRepeat/repeats:3_median\", "
anatofuz
parents:
diff changeset
36 "\"name\": \"BM_SummaryRepeat/repeats:3_stddev\"\nThe entire "
anatofuz
parents:
diff changeset
37 "output:\n";
anatofuz
parents:
diff changeset
38 std::cout << output;
anatofuz
parents:
diff changeset
39 return 1;
anatofuz
parents:
diff changeset
40 }
anatofuz
parents:
diff changeset
41
anatofuz
parents:
diff changeset
42 return 0;
anatofuz
parents:
diff changeset
43 }