From 6113cf12d10e08d8df15a424f96b7032d1300be8 Mon Sep 17 00:00:00 2001 From: Louis Dionne Date: Thu, 19 Dec 2024 13:24:55 -0500 Subject: [PATCH] [libc++] Fix the batch sized used in the std::gcd benchmark 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. --- libcxx/test/benchmarks/numeric/gcd.bench.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libcxx/test/benchmarks/numeric/gcd.bench.cpp b/libcxx/test/benchmarks/numeric/gcd.bench.cpp index abbc7e9dd04f9..ca5fed59463a2 100644 --- a/libcxx/test/benchmarks/numeric/gcd.bench.cpp +++ b/libcxx/test/benchmarks/numeric/gcd.bench.cpp @@ -25,7 +25,7 @@ static std::array generate(std::uniform_int_distribution distributio static void bm_gcd_random(benchmark::State& state) { std::array data = generate(); - 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));