[libcxx-commits] [libcxx] [libc++] Give proper names to a few benchmarks (PR #183333)

Louis Dionne via libcxx-commits libcxx-commits at lists.llvm.org
Wed Feb 25 08:36:17 PST 2026


https://github.com/ldionne created https://github.com/llvm/llvm-project/pull/183333

None

>From 2039ec1d150a9598a4c7ba8ecbdc686eb48e9ad7 Mon Sep 17 00:00:00 2001
From: Louis Dionne <ldionne.2 at gmail.com>
Date: Wed, 25 Feb 2026 11:35:36 -0500
Subject: [PATCH] [libc++] Give proper names to a few benchmarks

---
 libcxx/test/benchmarks/numeric/gcd.bench.cpp      | 6 +++---
 libcxx/test/benchmarks/streams/getline.bench.cpp  | 2 +-
 libcxx/test/benchmarks/streams/ofstream.bench.cpp | 2 +-
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/libcxx/test/benchmarks/numeric/gcd.bench.cpp b/libcxx/test/benchmarks/numeric/gcd.bench.cpp
index ca5fed59463a2..008968eeda90a 100644
--- a/libcxx/test/benchmarks/numeric/gcd.bench.cpp
+++ b/libcxx/test/benchmarks/numeric/gcd.bench.cpp
@@ -30,7 +30,7 @@ static void bm_gcd_random(benchmark::State& state) {
       for (auto v1 : data)
         benchmark::DoNotOptimize(std::gcd(v0, v1));
 }
-BENCHMARK(bm_gcd_random);
+BENCHMARK(bm_gcd_random)->Name("std::gcd() (random numbers)");
 
 static void bm_gcd_trivial(benchmark::State& state) {
   int lhs = ~static_cast<int>(0), rhs = 1;
@@ -40,7 +40,7 @@ static void bm_gcd_trivial(benchmark::State& state) {
     benchmark::DoNotOptimize(std::gcd(lhs, rhs));
   }
 }
-BENCHMARK(bm_gcd_trivial);
+BENCHMARK(bm_gcd_trivial)->Name("std::gcd() (trivial inputs)");
 
 static void bm_gcd_complex(benchmark::State& state) {
   long long lhs = 2971215073;
@@ -51,6 +51,6 @@ static void bm_gcd_complex(benchmark::State& state) {
     benchmark::DoNotOptimize(std::gcd(lhs, rhs));
   }
 }
-BENCHMARK(bm_gcd_complex);
+BENCHMARK(bm_gcd_complex)->Name("std::gcd() (adversary inputs)");
 
 BENCHMARK_MAIN();
diff --git a/libcxx/test/benchmarks/streams/getline.bench.cpp b/libcxx/test/benchmarks/streams/getline.bench.cpp
index 5ccefce876224..74fb4d12ae971 100644
--- a/libcxx/test/benchmarks/streams/getline.bench.cpp
+++ b/libcxx/test/benchmarks/streams/getline.bench.cpp
@@ -29,6 +29,6 @@ void BM_getline_string(benchmark::State& state) {
   }
 }
 
-BENCHMARK(BM_getline_string);
+BENCHMARK(BM_getline_string)->Name("std::getline(std::istringstream, std::string)");
 
 BENCHMARK_MAIN();
diff --git a/libcxx/test/benchmarks/streams/ofstream.bench.cpp b/libcxx/test/benchmarks/streams/ofstream.bench.cpp
index 60606a9d67e2f..eb50a41ed4ed4 100644
--- a/libcxx/test/benchmarks/streams/ofstream.bench.cpp
+++ b/libcxx/test/benchmarks/streams/ofstream.bench.cpp
@@ -20,6 +20,6 @@ static void bm_write(benchmark::State& state) {
   for (auto _ : state)
     stream.write(buffer.data(), buffer.size());
 }
-BENCHMARK(bm_write);
+BENCHMARK(bm_write)->Name("std::ofstream::write(char*, size)");
 
 BENCHMARK_MAIN();



More information about the libcxx-commits mailing list