2021-06-02 17:34:00 +08:00
|
|
|
|
|
|
|
#include "benchmark/benchmark.h"
|
|
|
|
#include "output_test.h"
|
|
|
|
|
|
|
|
// ========================================================================= //
|
|
|
|
// ------------------------ Testing Basic Output --------------------------- //
|
|
|
|
// ========================================================================= //
|
|
|
|
|
2021-06-29 18:06:53 +08:00
|
|
|
static void BM_ExplicitRepetitions(benchmark::State& state) {
|
2021-06-02 17:34:00 +08:00
|
|
|
for (auto _ : state) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
BENCHMARK(BM_ExplicitRepetitions)->Repetitions(2);
|
|
|
|
|
|
|
|
ADD_CASES(TC_ConsoleOut,
|
|
|
|
{{"^BM_ExplicitRepetitions/repeats:2 %console_report$"}});
|
|
|
|
ADD_CASES(TC_ConsoleOut,
|
|
|
|
{{"^BM_ExplicitRepetitions/repeats:2 %console_report$"}});
|
|
|
|
ADD_CASES(TC_ConsoleOut,
|
|
|
|
{{"^BM_ExplicitRepetitions/repeats:2_mean %console_report$"}});
|
|
|
|
ADD_CASES(TC_ConsoleOut,
|
|
|
|
{{"^BM_ExplicitRepetitions/repeats:2_median %console_report$"}});
|
|
|
|
ADD_CASES(TC_ConsoleOut,
|
|
|
|
{{"^BM_ExplicitRepetitions/repeats:2_stddev %console_report$"}});
|
|
|
|
ADD_CASES(TC_JSONOut,
|
|
|
|
{{"\"name\": \"BM_ExplicitRepetitions/repeats:2\",$"},
|
2021-06-02 23:06:45 +08:00
|
|
|
{"\"family_index\": 0,$", MR_Next},
|
2021-06-03 04:45:41 +08:00
|
|
|
{"\"per_family_instance_index\": 0,$", MR_Next},
|
2021-06-02 17:34:00 +08:00
|
|
|
{"\"run_name\": \"BM_ExplicitRepetitions/repeats:2\",$", MR_Next},
|
|
|
|
{"\"run_type\": \"iteration\",$", MR_Next},
|
|
|
|
{"\"repetitions\": 2,$", MR_Next},
|
|
|
|
{"\"repetition_index\": 0,$", MR_Next},
|
|
|
|
{"\"threads\": 1,$", MR_Next},
|
|
|
|
{"\"iterations\": %int,$", MR_Next},
|
|
|
|
{"\"real_time\": %float,$", MR_Next},
|
|
|
|
{"\"cpu_time\": %float,$", MR_Next},
|
|
|
|
{"\"time_unit\": \"ns\"$", MR_Next},
|
|
|
|
{"}", MR_Next}});
|
|
|
|
ADD_CASES(TC_JSONOut,
|
|
|
|
{{"\"name\": \"BM_ExplicitRepetitions/repeats:2\",$"},
|
2021-06-02 23:06:45 +08:00
|
|
|
{"\"family_index\": 0,$", MR_Next},
|
2021-06-03 04:45:41 +08:00
|
|
|
{"\"per_family_instance_index\": 0,$", MR_Next},
|
2021-06-02 17:34:00 +08:00
|
|
|
{"\"run_name\": \"BM_ExplicitRepetitions/repeats:2\",$", MR_Next},
|
|
|
|
{"\"run_type\": \"iteration\",$", MR_Next},
|
|
|
|
{"\"repetitions\": 2,$", MR_Next},
|
|
|
|
{"\"repetition_index\": 1,$", MR_Next},
|
|
|
|
{"\"threads\": 1,$", MR_Next},
|
|
|
|
{"\"iterations\": %int,$", MR_Next},
|
|
|
|
{"\"real_time\": %float,$", MR_Next},
|
|
|
|
{"\"cpu_time\": %float,$", MR_Next},
|
|
|
|
{"\"time_unit\": \"ns\"$", MR_Next},
|
|
|
|
{"}", MR_Next}});
|
|
|
|
ADD_CASES(TC_JSONOut,
|
|
|
|
{{"\"name\": \"BM_ExplicitRepetitions/repeats:2_mean\",$"},
|
2021-06-02 23:06:45 +08:00
|
|
|
{"\"family_index\": 0,$", MR_Next},
|
2021-06-03 04:45:41 +08:00
|
|
|
{"\"per_family_instance_index\": 0,$", MR_Next},
|
2021-06-02 17:34:00 +08:00
|
|
|
{"\"run_name\": \"BM_ExplicitRepetitions/repeats:2\",$", MR_Next},
|
|
|
|
{"\"run_type\": \"aggregate\",$", MR_Next},
|
|
|
|
{"\"repetitions\": 2,$", MR_Next},
|
|
|
|
{"\"threads\": 1,$", MR_Next},
|
|
|
|
{"\"aggregate_name\": \"mean\",$", MR_Next},
|
Statistics: add support for percentage unit in addition to time (#1219)
* Statistics: add support for percentage unit in addition to time
I think, `stddev` statistic is useful, but confusing.
What does it mean if `stddev` of `1ms` is reported?
Is that good or bad? If the `median` is `1s`,
then that means that the measurements are pretty noise-less.
And what about `stddev` of `100ms` is reported?
If the `median` is `1s` - awful, if the `median` is `10s` - good.
And hurray, there is just the statistic that we need:
https://en.wikipedia.org/wiki/Coefficient_of_variation
But, naturally, that produces a value in percents,
but the statistics are currently hardcoded to produce time.
So this refactors thinkgs a bit, and allows a percentage unit for statistics.
I'm not sure whether or not `benchmark` would be okay
with adding this `RSD` statistic by default,
but regales, that is a separate patch.
Refs. https://github.com/google/benchmark/issues/1146
* Address review notes
2021-09-03 22:36:56 +08:00
|
|
|
{"\"aggregate_unit\": \"time\",$", MR_Next},
|
2021-06-02 17:34:00 +08:00
|
|
|
{"\"iterations\": %int,$", MR_Next},
|
|
|
|
{"\"real_time\": %float,$", MR_Next},
|
|
|
|
{"\"cpu_time\": %float,$", MR_Next},
|
|
|
|
{"\"time_unit\": \"ns\"$", MR_Next},
|
|
|
|
{"}", MR_Next}});
|
|
|
|
ADD_CASES(TC_JSONOut,
|
|
|
|
{{"\"name\": \"BM_ExplicitRepetitions/repeats:2_median\",$"},
|
2021-06-02 23:06:45 +08:00
|
|
|
{"\"family_index\": 0,$", MR_Next},
|
2021-06-03 04:45:41 +08:00
|
|
|
{"\"per_family_instance_index\": 0,$", MR_Next},
|
2021-06-02 17:34:00 +08:00
|
|
|
{"\"run_name\": \"BM_ExplicitRepetitions/repeats:2\",$", MR_Next},
|
|
|
|
{"\"run_type\": \"aggregate\",$", MR_Next},
|
|
|
|
{"\"repetitions\": 2,$", MR_Next},
|
|
|
|
{"\"threads\": 1,$", MR_Next},
|
|
|
|
{"\"aggregate_name\": \"median\",$", MR_Next},
|
Statistics: add support for percentage unit in addition to time (#1219)
* Statistics: add support for percentage unit in addition to time
I think, `stddev` statistic is useful, but confusing.
What does it mean if `stddev` of `1ms` is reported?
Is that good or bad? If the `median` is `1s`,
then that means that the measurements are pretty noise-less.
And what about `stddev` of `100ms` is reported?
If the `median` is `1s` - awful, if the `median` is `10s` - good.
And hurray, there is just the statistic that we need:
https://en.wikipedia.org/wiki/Coefficient_of_variation
But, naturally, that produces a value in percents,
but the statistics are currently hardcoded to produce time.
So this refactors thinkgs a bit, and allows a percentage unit for statistics.
I'm not sure whether or not `benchmark` would be okay
with adding this `RSD` statistic by default,
but regales, that is a separate patch.
Refs. https://github.com/google/benchmark/issues/1146
* Address review notes
2021-09-03 22:36:56 +08:00
|
|
|
{"\"aggregate_unit\": \"time\",$", MR_Next},
|
2021-06-02 17:34:00 +08:00
|
|
|
{"\"iterations\": %int,$", MR_Next},
|
|
|
|
{"\"real_time\": %float,$", MR_Next},
|
|
|
|
{"\"cpu_time\": %float,$", MR_Next},
|
|
|
|
{"\"time_unit\": \"ns\"$", MR_Next},
|
|
|
|
{"}", MR_Next}});
|
|
|
|
ADD_CASES(TC_JSONOut,
|
|
|
|
{{"\"name\": \"BM_ExplicitRepetitions/repeats:2_stddev\",$"},
|
2021-06-02 23:06:45 +08:00
|
|
|
{"\"family_index\": 0,$", MR_Next},
|
2021-06-03 04:45:41 +08:00
|
|
|
{"\"per_family_instance_index\": 0,$", MR_Next},
|
2021-06-02 17:34:00 +08:00
|
|
|
{"\"run_name\": \"BM_ExplicitRepetitions/repeats:2\",$", MR_Next},
|
|
|
|
{"\"run_type\": \"aggregate\",$", MR_Next},
|
|
|
|
{"\"repetitions\": 2,$", MR_Next},
|
|
|
|
{"\"threads\": 1,$", MR_Next},
|
|
|
|
{"\"aggregate_name\": \"stddev\",$", MR_Next},
|
Statistics: add support for percentage unit in addition to time (#1219)
* Statistics: add support for percentage unit in addition to time
I think, `stddev` statistic is useful, but confusing.
What does it mean if `stddev` of `1ms` is reported?
Is that good or bad? If the `median` is `1s`,
then that means that the measurements are pretty noise-less.
And what about `stddev` of `100ms` is reported?
If the `median` is `1s` - awful, if the `median` is `10s` - good.
And hurray, there is just the statistic that we need:
https://en.wikipedia.org/wiki/Coefficient_of_variation
But, naturally, that produces a value in percents,
but the statistics are currently hardcoded to produce time.
So this refactors thinkgs a bit, and allows a percentage unit for statistics.
I'm not sure whether or not `benchmark` would be okay
with adding this `RSD` statistic by default,
but regales, that is a separate patch.
Refs. https://github.com/google/benchmark/issues/1146
* Address review notes
2021-09-03 22:36:56 +08:00
|
|
|
{"\"aggregate_unit\": \"time\",$", MR_Next},
|
2021-06-02 17:34:00 +08:00
|
|
|
{"\"iterations\": %int,$", MR_Next},
|
|
|
|
{"\"real_time\": %float,$", MR_Next},
|
|
|
|
{"\"cpu_time\": %float,$", MR_Next},
|
|
|
|
{"\"time_unit\": \"ns\"$", MR_Next},
|
|
|
|
{"}", MR_Next}});
|
|
|
|
ADD_CASES(TC_CSVOut, {{"^\"BM_ExplicitRepetitions/repeats:2\",%csv_report$"}});
|
|
|
|
ADD_CASES(TC_CSVOut, {{"^\"BM_ExplicitRepetitions/repeats:2\",%csv_report$"}});
|
|
|
|
ADD_CASES(TC_CSVOut,
|
|
|
|
{{"^\"BM_ExplicitRepetitions/repeats:2_mean\",%csv_report$"}});
|
|
|
|
ADD_CASES(TC_CSVOut,
|
|
|
|
{{"^\"BM_ExplicitRepetitions/repeats:2_median\",%csv_report$"}});
|
|
|
|
ADD_CASES(TC_CSVOut,
|
|
|
|
{{"^\"BM_ExplicitRepetitions/repeats:2_stddev\",%csv_report$"}});
|
|
|
|
|
|
|
|
// ========================================================================= //
|
|
|
|
// ------------------------ Testing Basic Output --------------------------- //
|
|
|
|
// ========================================================================= //
|
|
|
|
|
2021-06-29 18:06:53 +08:00
|
|
|
static void BM_ImplicitRepetitions(benchmark::State& state) {
|
2021-06-02 17:34:00 +08:00
|
|
|
for (auto _ : state) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
BENCHMARK(BM_ImplicitRepetitions);
|
|
|
|
|
|
|
|
ADD_CASES(TC_ConsoleOut, {{"^BM_ImplicitRepetitions %console_report$"}});
|
|
|
|
ADD_CASES(TC_ConsoleOut, {{"^BM_ImplicitRepetitions %console_report$"}});
|
|
|
|
ADD_CASES(TC_ConsoleOut, {{"^BM_ImplicitRepetitions %console_report$"}});
|
|
|
|
ADD_CASES(TC_ConsoleOut, {{"^BM_ImplicitRepetitions_mean %console_report$"}});
|
|
|
|
ADD_CASES(TC_ConsoleOut, {{"^BM_ImplicitRepetitions_median %console_report$"}});
|
|
|
|
ADD_CASES(TC_ConsoleOut, {{"^BM_ImplicitRepetitions_stddev %console_report$"}});
|
|
|
|
ADD_CASES(TC_JSONOut, {{"\"name\": \"BM_ImplicitRepetitions\",$"},
|
2021-06-02 23:06:45 +08:00
|
|
|
{"\"family_index\": 1,$", MR_Next},
|
2021-06-03 04:45:41 +08:00
|
|
|
{"\"per_family_instance_index\": 0,$", MR_Next},
|
2021-06-02 17:34:00 +08:00
|
|
|
{"\"run_name\": \"BM_ImplicitRepetitions\",$", MR_Next},
|
|
|
|
{"\"run_type\": \"iteration\",$", MR_Next},
|
|
|
|
{"\"repetitions\": 3,$", MR_Next},
|
|
|
|
{"\"repetition_index\": 0,$", MR_Next},
|
|
|
|
{"\"threads\": 1,$", MR_Next},
|
|
|
|
{"\"iterations\": %int,$", MR_Next},
|
|
|
|
{"\"real_time\": %float,$", MR_Next},
|
|
|
|
{"\"cpu_time\": %float,$", MR_Next},
|
|
|
|
{"\"time_unit\": \"ns\"$", MR_Next},
|
|
|
|
{"}", MR_Next}});
|
|
|
|
ADD_CASES(TC_JSONOut, {{"\"name\": \"BM_ImplicitRepetitions\",$"},
|
2021-06-02 23:06:45 +08:00
|
|
|
{"\"family_index\": 1,$", MR_Next},
|
2021-06-03 04:45:41 +08:00
|
|
|
{"\"per_family_instance_index\": 0,$", MR_Next},
|
2021-06-02 17:34:00 +08:00
|
|
|
{"\"run_name\": \"BM_ImplicitRepetitions\",$", MR_Next},
|
|
|
|
{"\"run_type\": \"iteration\",$", MR_Next},
|
|
|
|
{"\"repetitions\": 3,$", MR_Next},
|
|
|
|
{"\"repetition_index\": 1,$", MR_Next},
|
|
|
|
{"\"threads\": 1,$", MR_Next},
|
|
|
|
{"\"iterations\": %int,$", MR_Next},
|
|
|
|
{"\"real_time\": %float,$", MR_Next},
|
|
|
|
{"\"cpu_time\": %float,$", MR_Next},
|
|
|
|
{"\"time_unit\": \"ns\"$", MR_Next},
|
|
|
|
{"}", MR_Next}});
|
|
|
|
ADD_CASES(TC_JSONOut, {{"\"name\": \"BM_ImplicitRepetitions\",$"},
|
2021-06-02 23:06:45 +08:00
|
|
|
{"\"family_index\": 1,$", MR_Next},
|
2021-06-03 04:45:41 +08:00
|
|
|
{"\"per_family_instance_index\": 0,$", MR_Next},
|
2021-06-02 17:34:00 +08:00
|
|
|
{"\"run_name\": \"BM_ImplicitRepetitions\",$", MR_Next},
|
|
|
|
{"\"run_type\": \"iteration\",$", MR_Next},
|
|
|
|
{"\"repetitions\": 3,$", MR_Next},
|
|
|
|
{"\"repetition_index\": 2,$", MR_Next},
|
|
|
|
{"\"threads\": 1,$", MR_Next},
|
|
|
|
{"\"iterations\": %int,$", MR_Next},
|
|
|
|
{"\"real_time\": %float,$", MR_Next},
|
|
|
|
{"\"cpu_time\": %float,$", MR_Next},
|
|
|
|
{"\"time_unit\": \"ns\"$", MR_Next},
|
|
|
|
{"}", MR_Next}});
|
|
|
|
ADD_CASES(TC_JSONOut, {{"\"name\": \"BM_ImplicitRepetitions_mean\",$"},
|
2021-06-02 23:06:45 +08:00
|
|
|
{"\"family_index\": 1,$", MR_Next},
|
2021-06-03 04:45:41 +08:00
|
|
|
{"\"per_family_instance_index\": 0,$", MR_Next},
|
2021-06-02 17:34:00 +08:00
|
|
|
{"\"run_name\": \"BM_ImplicitRepetitions\",$", MR_Next},
|
|
|
|
{"\"run_type\": \"aggregate\",$", MR_Next},
|
|
|
|
{"\"repetitions\": 3,$", MR_Next},
|
|
|
|
{"\"threads\": 1,$", MR_Next},
|
|
|
|
{"\"aggregate_name\": \"mean\",$", MR_Next},
|
Statistics: add support for percentage unit in addition to time (#1219)
* Statistics: add support for percentage unit in addition to time
I think, `stddev` statistic is useful, but confusing.
What does it mean if `stddev` of `1ms` is reported?
Is that good or bad? If the `median` is `1s`,
then that means that the measurements are pretty noise-less.
And what about `stddev` of `100ms` is reported?
If the `median` is `1s` - awful, if the `median` is `10s` - good.
And hurray, there is just the statistic that we need:
https://en.wikipedia.org/wiki/Coefficient_of_variation
But, naturally, that produces a value in percents,
but the statistics are currently hardcoded to produce time.
So this refactors thinkgs a bit, and allows a percentage unit for statistics.
I'm not sure whether or not `benchmark` would be okay
with adding this `RSD` statistic by default,
but regales, that is a separate patch.
Refs. https://github.com/google/benchmark/issues/1146
* Address review notes
2021-09-03 22:36:56 +08:00
|
|
|
{"\"aggregate_unit\": \"time\",$", MR_Next},
|
2021-06-02 17:34:00 +08:00
|
|
|
{"\"iterations\": %int,$", MR_Next},
|
|
|
|
{"\"real_time\": %float,$", MR_Next},
|
|
|
|
{"\"cpu_time\": %float,$", MR_Next},
|
|
|
|
{"\"time_unit\": \"ns\"$", MR_Next},
|
|
|
|
{"}", MR_Next}});
|
|
|
|
ADD_CASES(TC_JSONOut, {{"\"name\": \"BM_ImplicitRepetitions_median\",$"},
|
2021-06-02 23:06:45 +08:00
|
|
|
{"\"family_index\": 1,$", MR_Next},
|
2021-06-03 04:45:41 +08:00
|
|
|
{"\"per_family_instance_index\": 0,$", MR_Next},
|
2021-06-02 17:34:00 +08:00
|
|
|
{"\"run_name\": \"BM_ImplicitRepetitions\",$", MR_Next},
|
|
|
|
{"\"run_type\": \"aggregate\",$", MR_Next},
|
|
|
|
{"\"repetitions\": 3,$", MR_Next},
|
|
|
|
{"\"threads\": 1,$", MR_Next},
|
|
|
|
{"\"aggregate_name\": \"median\",$", MR_Next},
|
Statistics: add support for percentage unit in addition to time (#1219)
* Statistics: add support for percentage unit in addition to time
I think, `stddev` statistic is useful, but confusing.
What does it mean if `stddev` of `1ms` is reported?
Is that good or bad? If the `median` is `1s`,
then that means that the measurements are pretty noise-less.
And what about `stddev` of `100ms` is reported?
If the `median` is `1s` - awful, if the `median` is `10s` - good.
And hurray, there is just the statistic that we need:
https://en.wikipedia.org/wiki/Coefficient_of_variation
But, naturally, that produces a value in percents,
but the statistics are currently hardcoded to produce time.
So this refactors thinkgs a bit, and allows a percentage unit for statistics.
I'm not sure whether or not `benchmark` would be okay
with adding this `RSD` statistic by default,
but regales, that is a separate patch.
Refs. https://github.com/google/benchmark/issues/1146
* Address review notes
2021-09-03 22:36:56 +08:00
|
|
|
{"\"aggregate_unit\": \"time\",$", MR_Next},
|
2021-06-02 17:34:00 +08:00
|
|
|
{"\"iterations\": %int,$", MR_Next},
|
|
|
|
{"\"real_time\": %float,$", MR_Next},
|
|
|
|
{"\"cpu_time\": %float,$", MR_Next},
|
|
|
|
{"\"time_unit\": \"ns\"$", MR_Next},
|
|
|
|
{"}", MR_Next}});
|
|
|
|
ADD_CASES(TC_JSONOut, {{"\"name\": \"BM_ImplicitRepetitions_stddev\",$"},
|
2021-06-02 23:06:45 +08:00
|
|
|
{"\"family_index\": 1,$", MR_Next},
|
2021-06-03 04:45:41 +08:00
|
|
|
{"\"per_family_instance_index\": 0,$", MR_Next},
|
2021-06-02 17:34:00 +08:00
|
|
|
{"\"run_name\": \"BM_ImplicitRepetitions\",$", MR_Next},
|
|
|
|
{"\"run_type\": \"aggregate\",$", MR_Next},
|
|
|
|
{"\"repetitions\": 3,$", MR_Next},
|
|
|
|
{"\"threads\": 1,$", MR_Next},
|
|
|
|
{"\"aggregate_name\": \"stddev\",$", MR_Next},
|
Statistics: add support for percentage unit in addition to time (#1219)
* Statistics: add support for percentage unit in addition to time
I think, `stddev` statistic is useful, but confusing.
What does it mean if `stddev` of `1ms` is reported?
Is that good or bad? If the `median` is `1s`,
then that means that the measurements are pretty noise-less.
And what about `stddev` of `100ms` is reported?
If the `median` is `1s` - awful, if the `median` is `10s` - good.
And hurray, there is just the statistic that we need:
https://en.wikipedia.org/wiki/Coefficient_of_variation
But, naturally, that produces a value in percents,
but the statistics are currently hardcoded to produce time.
So this refactors thinkgs a bit, and allows a percentage unit for statistics.
I'm not sure whether or not `benchmark` would be okay
with adding this `RSD` statistic by default,
but regales, that is a separate patch.
Refs. https://github.com/google/benchmark/issues/1146
* Address review notes
2021-09-03 22:36:56 +08:00
|
|
|
{"\"aggregate_unit\": \"time\",$", MR_Next},
|
2021-06-02 17:34:00 +08:00
|
|
|
{"\"iterations\": %int,$", MR_Next},
|
|
|
|
{"\"real_time\": %float,$", MR_Next},
|
|
|
|
{"\"cpu_time\": %float,$", MR_Next},
|
|
|
|
{"\"time_unit\": \"ns\"$", MR_Next},
|
|
|
|
{"}", MR_Next}});
|
|
|
|
ADD_CASES(TC_CSVOut, {{"^\"BM_ImplicitRepetitions\",%csv_report$"}});
|
|
|
|
ADD_CASES(TC_CSVOut, {{"^\"BM_ImplicitRepetitions\",%csv_report$"}});
|
|
|
|
ADD_CASES(TC_CSVOut, {{"^\"BM_ImplicitRepetitions_mean\",%csv_report$"}});
|
|
|
|
ADD_CASES(TC_CSVOut, {{"^\"BM_ImplicitRepetitions_median\",%csv_report$"}});
|
|
|
|
ADD_CASES(TC_CSVOut, {{"^\"BM_ImplicitRepetitions_stddev\",%csv_report$"}});
|
|
|
|
|
|
|
|
// ========================================================================= //
|
|
|
|
// --------------------------- TEST CASES END ------------------------------ //
|
|
|
|
// ========================================================================= //
|
|
|
|
|
|
|
|
int main(int argc, char* argv[]) { RunOutputTests(argc, argv); }
|