2018-07-24 14:57:15 +00:00
|
|
|
#include <memory>
|
|
|
|
|
|
|
|
#include "../src/check.h"
|
|
|
|
#include "benchmark/benchmark.h"
|
|
|
|
#include "output_test.h"
|
|
|
|
|
|
|
|
class TestMemoryManager : public benchmark::MemoryManager {
|
2023-01-09 17:52:18 +00:00
|
|
|
void Start() override {}
|
|
|
|
void Stop(Result& result) override {
|
2022-11-11 15:12:12 +00:00
|
|
|
result.num_allocs = 42;
|
|
|
|
result.max_bytes_used = 42000;
|
2018-07-24 14:57:15 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
void BM_empty(benchmark::State& state) {
|
|
|
|
for (auto _ : state) {
|
|
|
|
benchmark::DoNotOptimize(state.iterations());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
BENCHMARK(BM_empty);
|
|
|
|
|
|
|
|
ADD_CASES(TC_ConsoleOut, {{"^BM_empty %console_report$"}});
|
|
|
|
ADD_CASES(TC_JSONOut, {{"\"name\": \"BM_empty\",$"},
|
2021-06-02 15:06:45 +00:00
|
|
|
{"\"family_index\": 0,$", MR_Next},
|
2021-06-02 20:45:41 +00:00
|
|
|
{"\"per_family_instance_index\": 0,$", MR_Next},
|
Track two more details about runs - the aggregate name, and run name. (#675)
This is related to @BaaMeow's work in https://github.com/google/benchmark/pull/616 but is not based on it.
Two new fields are tracked, and dumped into JSON:
* If the run is an aggregate, the aggregate's name is stored.
It can be RMS, BigO, mean, median, stddev, or any custom stat name.
* The aggregate-name-less run name is additionally stored.
I.e. not some name of the benchmark function, but the actual
name, but without the 'aggregate name' suffix.
This way one can group/filter all the runs,
and filter by the particular aggregate type.
I *might* need this for further tooling improvement.
Or maybe not.
But this is certainly worthwhile for custom tooling.
2018-09-13 12:08:15 +00:00
|
|
|
{"\"run_name\": \"BM_empty\",$", MR_Next},
|
Track 'type' of the run - is it an actual measurement, or an aggregate. (#658)
This is *only* exposed in the JSON. Not in CSV, which is deprecated.
This *only* supposed to track these two states.
An additional field could later track which aggregate this is,
specifically (statistic name, rms, bigo, ...)
The motivation is that we already have ReportAggregatesOnly,
but it affects the entire reports, both the display,
and the reporters (json files), which isn't ideal.
It would be very useful to have a 'display aggregates only' option,
both in the library's console reporter, and the python tooling,
This will be especially needed for the 'store separate iterations'.
2018-08-28 15:11:36 +00:00
|
|
|
{"\"run_type\": \"iteration\",$", MR_Next},
|
2021-06-02 09:34:00 +00:00
|
|
|
{"\"repetitions\": 1,$", MR_Next},
|
2019-03-26 09:53:07 +00:00
|
|
|
{"\"repetition_index\": 0,$", MR_Next},
|
|
|
|
{"\"threads\": 1,$", MR_Next},
|
2018-07-24 14:57:15 +00:00
|
|
|
{"\"iterations\": %int,$", MR_Next},
|
|
|
|
{"\"real_time\": %float,$", MR_Next},
|
|
|
|
{"\"cpu_time\": %float,$", MR_Next},
|
|
|
|
{"\"time_unit\": \"ns\",$", MR_Next},
|
|
|
|
{"\"allocs_per_iter\": %float,$", MR_Next},
|
|
|
|
{"\"max_bytes_used\": 42000$", MR_Next},
|
|
|
|
{"}", MR_Next}});
|
|
|
|
ADD_CASES(TC_CSVOut, {{"^\"BM_empty\",%csv_report$"}});
|
|
|
|
|
2019-03-26 09:53:07 +00:00
|
|
|
int main(int argc, char* argv[]) {
|
2018-07-24 14:57:15 +00:00
|
|
|
std::unique_ptr<benchmark::MemoryManager> mm(new TestMemoryManager());
|
|
|
|
|
|
|
|
benchmark::RegisterMemoryManager(mm.get());
|
|
|
|
RunOutputTests(argc, argv);
|
|
|
|
benchmark::RegisterMemoryManager(nullptr);
|
|
|
|
}
|