[libcxx-commits] [libcxx] [libc++] Fix the batch sized used in the std::gcd benchmark (PR #120618)
via libcxx-commits
libcxx-commits at lists.llvm.org
Thu Dec 19 10:27:19 PST 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-libcxx
Author: Louis Dionne (ldionne)
<details>
<summary>Changes</summary>
Since that benchmark is testing n*n inputs, the batch size reported to GoogleBenchmark should be that amount. Otherwise, GoogleBenchmark reports the timing for calling std::gcd on the whole sequence, which is misleading.
---
Full diff: https://github.com/llvm/llvm-project/pull/120618.diff
1 Files Affected:
- (modified) libcxx/test/benchmarks/numeric/gcd.bench.cpp (+1-1)
``````````diff
diff --git a/libcxx/test/benchmarks/numeric/gcd.bench.cpp b/libcxx/test/benchmarks/numeric/gcd.bench.cpp
index abbc7e9dd04f96..ca5fed59463a21 100644
--- a/libcxx/test/benchmarks/numeric/gcd.bench.cpp
+++ b/libcxx/test/benchmarks/numeric/gcd.bench.cpp
@@ -25,7 +25,7 @@ static std::array<T, 1000> generate(std::uniform_int_distribution<T> distributio
static void bm_gcd_random(benchmark::State& state) {
std::array data = generate<int>();
- while (state.KeepRunningBatch(data.size()))
+ while (state.KeepRunningBatch(data.size() * data.size()))
for (auto v0 : data)
for (auto v1 : data)
benchmark::DoNotOptimize(std::gcd(v0, v1));
``````````
</details>
https://github.com/llvm/llvm-project/pull/120618
More information about the libcxx-commits
mailing list