1 // FIXME: WIP
2
3 #include <memory>
4
5 #include "benchmark/benchmark.h"
6 #include "output_test.h"
7
8 class TestProfilerManager : public benchmark::ProfilerManager {
9 public:
AfterSetupStart()10 void AfterSetupStart() override { ++start_called; }
BeforeTeardownStop()11 void BeforeTeardownStop() override { ++stop_called; }
12
13 int start_called = 0;
14 int stop_called = 0;
15 };
16
BM_empty(benchmark::State & state)17 void BM_empty(benchmark::State& state) {
18 for (auto _ : state) {
19 auto iterations = state.iterations();
20 benchmark::DoNotOptimize(iterations);
21 }
22 }
23 BENCHMARK(BM_empty);
24
25 ADD_CASES(TC_ConsoleOut, {{"^BM_empty %console_report$"}});
26 ADD_CASES(TC_JSONOut, {{"\"name\": \"BM_empty\",$"},
27 {"\"family_index\": 0,$", MR_Next},
28 {"\"per_family_instance_index\": 0,$", MR_Next},
29 {"\"run_name\": \"BM_empty\",$", MR_Next},
30 {"\"run_type\": \"iteration\",$", MR_Next},
31 {"\"repetitions\": 1,$", MR_Next},
32 {"\"repetition_index\": 0,$", MR_Next},
33 {"\"threads\": 1,$", MR_Next},
34 {"\"iterations\": %int,$", MR_Next},
35 {"\"real_time\": %float,$", MR_Next},
36 {"\"cpu_time\": %float,$", MR_Next},
37 {"\"time_unit\": \"ns\"$", MR_Next},
38 {"}", MR_Next}});
39 ADD_CASES(TC_CSVOut, {{"^\"BM_empty\",%csv_report$"}});
40
main(int argc,char * argv[])41 int main(int argc, char* argv[]) {
42 std::unique_ptr<TestProfilerManager> pm(new TestProfilerManager());
43
44 benchmark::RegisterProfilerManager(pm.get());
45 RunOutputTests(argc, argv);
46 benchmark::RegisterProfilerManager(nullptr);
47
48 assert(pm->start_called == 1);
49 assert(pm->stop_called == 1);
50 }
51