[libcxx-commits] [libcxx] 15f30e7 - [libc++] Fix the batch size used in the std::gcd benchmark (#120618)

via libcxx-commits libcxx-commits at lists.llvm.org
Mon Jan 6 12:34:35 PST 2025


Author: Louis Dionne
Date: 2025-01-06T15:34:33-05:00
New Revision: 15f30e70eb18340fc422805707870e298d93161f

URL: https://github.com/llvm/llvm-project/commit/15f30e70eb18340fc422805707870e298d93161f
DIFF: https://github.com/llvm/llvm-project/commit/15f30e70eb18340fc422805707870e298d93161f.diff

LOG: [libc++] Fix the batch size used in the std::gcd benchmark (#120618)

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.

Added: 
    

Modified: 
    libcxx/test/benchmarks/numeric/gcd.bench.cpp

Removed: 
    


################################################################################
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));


        


More information about the libcxx-commits mailing list