3 #include "../src/check.h"
4 #include "benchmark/benchmark.h"
5 #include "output_test.h"
7 class TestMemoryManager
: public benchmark::MemoryManager
{
8 void Start() BENCHMARK_OVERRIDE
{}
9 void Stop(Result
* result
) BENCHMARK_OVERRIDE
{
10 result
->num_allocs
= 42;
11 result
->max_bytes_used
= 42000;
15 void BM_empty(benchmark::State
& state
) {
16 for (auto _
: state
) {
17 benchmark::DoNotOptimize(state
.iterations());
22 ADD_CASES(TC_ConsoleOut
, {{"^BM_empty %console_report$"}});
23 ADD_CASES(TC_JSONOut
, {{"\"name\": \"BM_empty\",$"},
24 {"\"family_index\": 0,$", MR_Next
},
25 {"\"per_family_instance_index\": 0,$", MR_Next
},
26 {"\"run_name\": \"BM_empty\",$", MR_Next
},
27 {"\"run_type\": \"iteration\",$", MR_Next
},
28 {"\"repetitions\": 1,$", MR_Next
},
29 {"\"repetition_index\": 0,$", MR_Next
},
30 {"\"threads\": 1,$", MR_Next
},
31 {"\"iterations\": %int,$", MR_Next
},
32 {"\"real_time\": %float,$", MR_Next
},
33 {"\"cpu_time\": %float,$", MR_Next
},
34 {"\"time_unit\": \"ns\",$", MR_Next
},
35 {"\"allocs_per_iter\": %float,$", MR_Next
},
36 {"\"max_bytes_used\": 42000$", MR_Next
},
38 ADD_CASES(TC_CSVOut
, {{"^\"BM_empty\",%csv_report$"}});
40 int main(int argc
, char* argv
[]) {
41 std::unique_ptr
<benchmark::MemoryManager
> mm(new TestMemoryManager());
43 benchmark::RegisterMemoryManager(mm
.get());
44 RunOutputTests(argc
, argv
);
45 benchmark::RegisterMemoryManager(nullptr);