Improve examples on ComputeStatistics (#1881)

This commit is contained in:
Guo Ci 2024-11-27 04:41:06 -05:00 committed by GitHub
parent 62a321d6dc
commit d26047a0ac
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1106,6 +1106,7 @@ void BM_spin_empty(benchmark::State& state) {
}
BENCHMARK(BM_spin_empty)
->Repetitions(3) // or add option --benchmark_repetitions=3
->ComputeStatistics("max", [](const std::vector<double>& v) -> double {
return *(std::max_element(std::begin(v), std::end(v)));
})
@ -1125,8 +1126,9 @@ void BM_spin_empty(benchmark::State& state) {
}
BENCHMARK(BM_spin_empty)
->Repetitions(3) // or add option --benchmark_repetitions=3
->ComputeStatistics("ratio", [](const std::vector<double>& v) -> double {
return std::begin(v) / std::end(v);
return v.front() / v.back();
}, benchmark::StatisticUnit::kPercentage)
->Arg(512);
```