[libcxx-commits] [libcxx] [libc++] Reduce the number of runs on the format_to{, n} and formatted_size benchmarks (PR #179922)
Nikolas Klauser via libcxx-commits
libcxx-commits at lists.llvm.org
Thu Feb 5 04:01:54 PST 2026
https://github.com/philnik777 created https://github.com/llvm/llvm-project/pull/179922
Testing a bunch of sizes has relatively little value. This reduces the number of benchmarks so we can run them on a regular basis.
>From 7f0a89871adad71a7f2073235f882b40bacff440 Mon Sep 17 00:00:00 2001
From: Nikolas Klauser <nikolasklauser at berlin.de>
Date: Thu, 5 Feb 2026 13:01:08 +0100
Subject: [PATCH] [libc++] Reduce the number of runs on the format_to{,n} and
formatted_size benchmarks
---
.../benchmarks/format/format_to.bench.cpp | 32 +++++++++----------
.../benchmarks/format/format_to_n.bench.cpp | 32 +++++++++----------
.../format/formatted_size.bench.cpp | 4 +--
3 files changed, 34 insertions(+), 34 deletions(-)
diff --git a/libcxx/test/benchmarks/format/format_to.bench.cpp b/libcxx/test/benchmarks/format/format_to.bench.cpp
index 5b06e826715e7..d1cbb49cad4e2 100644
--- a/libcxx/test/benchmarks/format/format_to.bench.cpp
+++ b/libcxx/test/benchmarks/format/format_to.bench.cpp
@@ -84,24 +84,24 @@ static void BM_format_to_string_pointer(benchmark::State& state) {
/*** Main ***/
-BENCHMARK(BM_format_to_string_back_inserter<std::string>)->RangeMultiplier(2)->Range(1, 1 << 20);
-BENCHMARK(BM_format_to_string_back_inserter<std::vector<char>>)->RangeMultiplier(2)->Range(1, 1 << 20);
-BENCHMARK(BM_format_to_string_back_inserter<std::list<char>>)->RangeMultiplier(2)->Range(1, 1 << 20);
-BENCHMARK(BM_format_to_string_begin<std::string>)->RangeMultiplier(2)->Range(1, 1 << 20);
-BENCHMARK(BM_format_to_string_begin<std::vector<char>>)->RangeMultiplier(2)->Range(1, 1 << 20);
-BENCHMARK(BM_format_to_string_begin<std::list<char>>)->RangeMultiplier(2)->Range(1, 1 << 20);
-BENCHMARK(BM_format_to_string_span<char>)->RangeMultiplier(2)->Range(1, 1 << 20);
-BENCHMARK(BM_format_to_string_pointer<char>)->RangeMultiplier(2)->Range(1, 1 << 20);
+BENCHMARK(BM_format_to_string_back_inserter<std::string>)->Arg(1)->Arg(16384)->Arg(1048576);
+BENCHMARK(BM_format_to_string_back_inserter<std::vector<char>>)->Arg(1)->Arg(16384)->Arg(1048576);
+BENCHMARK(BM_format_to_string_back_inserter<std::list<char>>)->Arg(1)->Arg(16384)->Arg(1048576);
+BENCHMARK(BM_format_to_string_begin<std::string>)->Arg(1)->Arg(16384)->Arg(1048576);
+BENCHMARK(BM_format_to_string_begin<std::vector<char>>)->Arg(1)->Arg(16384)->Arg(1048576);
+BENCHMARK(BM_format_to_string_begin<std::list<char>>)->Arg(1)->Arg(16384)->Arg(1048576);
+BENCHMARK(BM_format_to_string_span<char>)->Arg(1)->Arg(16384)->Arg(1048576);
+BENCHMARK(BM_format_to_string_pointer<char>)->Arg(1)->Arg(16384)->Arg(1048576);
#ifndef TEST_HAS_NO_WIDE_CHARACTERS
-BENCHMARK(BM_format_to_string_back_inserter<std::wstring>)->RangeMultiplier(2)->Range(1, 1 << 20);
-BENCHMARK(BM_format_to_string_back_inserter<std::vector<wchar_t>>)->RangeMultiplier(2)->Range(1, 1 << 20);
-BENCHMARK(BM_format_to_string_back_inserter<std::list<wchar_t>>)->RangeMultiplier(2)->Range(1, 1 << 20);
-BENCHMARK(BM_format_to_string_begin<std::wstring>)->RangeMultiplier(2)->Range(1, 1 << 20);
-BENCHMARK(BM_format_to_string_begin<std::vector<wchar_t>>)->RangeMultiplier(2)->Range(1, 1 << 20);
-BENCHMARK(BM_format_to_string_begin<std::list<wchar_t>>)->RangeMultiplier(2)->Range(1, 1 << 20);
-BENCHMARK(BM_format_to_string_span<wchar_t>)->RangeMultiplier(2)->Range(1, 1 << 20);
-BENCHMARK(BM_format_to_string_pointer<wchar_t>)->RangeMultiplier(2)->Range(1, 1 << 20);
+BENCHMARK(BM_format_to_string_back_inserter<std::wstring>)->Arg(1)->Arg(16384)->Arg(1048576);
+BENCHMARK(BM_format_to_string_back_inserter<std::vector<wchar_t>>)->Arg(1)->Arg(16384)->Arg(1048576);
+BENCHMARK(BM_format_to_string_back_inserter<std::list<wchar_t>>)->Arg(1)->Arg(16384)->Arg(1048576);
+BENCHMARK(BM_format_to_string_begin<std::wstring>)->Arg(1)->Arg(16384)->Arg(1048576);
+BENCHMARK(BM_format_to_string_begin<std::vector<wchar_t>>)->Arg(1)->Arg(16384)->Arg(1048576);
+BENCHMARK(BM_format_to_string_begin<std::list<wchar_t>>)->Arg(1)->Arg(16384)->Arg(1048576);
+BENCHMARK(BM_format_to_string_span<wchar_t>)->Arg(1)->Arg(16384)->Arg(1048576);
+BENCHMARK(BM_format_to_string_pointer<wchar_t>)->Arg(1)->Arg(16384)->Arg(1048576);
#endif
BENCHMARK_MAIN();
diff --git a/libcxx/test/benchmarks/format/format_to_n.bench.cpp b/libcxx/test/benchmarks/format/format_to_n.bench.cpp
index 30f6ce74f7c93..748c72f2c2866 100644
--- a/libcxx/test/benchmarks/format/format_to_n.bench.cpp
+++ b/libcxx/test/benchmarks/format/format_to_n.bench.cpp
@@ -84,24 +84,24 @@ static void BM_format_to_n_string_pointer(benchmark::State& state) {
/*** Main ***/
-BENCHMARK(BM_format_to_n_string_back_inserter<std::string>)->RangeMultiplier(2)->Range(1, 1 << 20);
-BENCHMARK(BM_format_to_n_string_back_inserter<std::vector<char>>)->RangeMultiplier(2)->Range(1, 1 << 20);
-BENCHMARK(BM_format_to_n_string_back_inserter<std::list<char>>)->RangeMultiplier(2)->Range(1, 1 << 20);
-BENCHMARK(BM_format_to_n_string_begin<std::string>)->RangeMultiplier(2)->Range(1, 1 << 20);
-BENCHMARK(BM_format_to_n_string_begin<std::vector<char>>)->RangeMultiplier(2)->Range(1, 1 << 20);
-BENCHMARK(BM_format_to_n_string_begin<std::list<char>>)->RangeMultiplier(2)->Range(1, 1 << 20);
-BENCHMARK(BM_format_to_n_string_span<char>)->RangeMultiplier(2)->Range(1, 1 << 20);
-BENCHMARK(BM_format_to_n_string_pointer<char>)->RangeMultiplier(2)->Range(1, 1 << 20);
+BENCHMARK(BM_format_to_n_string_back_inserter<std::string>)->Arg(1)->Arg(16384)->Arg(1048576);
+BENCHMARK(BM_format_to_n_string_back_inserter<std::vector<char>>)->Arg(1)->Arg(16384)->Arg(1048576);
+BENCHMARK(BM_format_to_n_string_back_inserter<std::list<char>>)->Arg(1)->Arg(16384)->Arg(1048576);
+BENCHMARK(BM_format_to_n_string_begin<std::string>)->Arg(1)->Arg(16384)->Arg(1048576);
+BENCHMARK(BM_format_to_n_string_begin<std::vector<char>>)->Arg(1)->Arg(16384)->Arg(1048576);
+BENCHMARK(BM_format_to_n_string_begin<std::list<char>>)->Arg(1)->Arg(16384)->Arg(1048576);
+BENCHMARK(BM_format_to_n_string_span<char>)->Arg(1)->Arg(16384)->Arg(1048576);
+BENCHMARK(BM_format_to_n_string_pointer<char>)->Arg(1)->Arg(16384)->Arg(1048576);
#ifndef TEST_HAS_NO_WIDE_CHARACTERS
-BENCHMARK(BM_format_to_n_string_back_inserter<std::wstring>)->RangeMultiplier(2)->Range(1, 1 << 20);
-BENCHMARK(BM_format_to_n_string_back_inserter<std::vector<wchar_t>>)->RangeMultiplier(2)->Range(1, 1 << 20);
-BENCHMARK(BM_format_to_n_string_back_inserter<std::list<wchar_t>>)->RangeMultiplier(2)->Range(1, 1 << 20);
-BENCHMARK(BM_format_to_n_string_begin<std::wstring>)->RangeMultiplier(2)->Range(1, 1 << 20);
-BENCHMARK(BM_format_to_n_string_begin<std::vector<wchar_t>>)->RangeMultiplier(2)->Range(1, 1 << 20);
-BENCHMARK(BM_format_to_n_string_begin<std::list<wchar_t>>)->RangeMultiplier(2)->Range(1, 1 << 20);
-BENCHMARK(BM_format_to_n_string_span<wchar_t>)->RangeMultiplier(2)->Range(1, 1 << 20);
-BENCHMARK(BM_format_to_n_string_pointer<wchar_t>)->RangeMultiplier(2)->Range(1, 1 << 20);
+BENCHMARK(BM_format_to_n_string_back_inserter<std::wstring>)->Arg(1)->Arg(16384)->Arg(1048576);
+BENCHMARK(BM_format_to_n_string_back_inserter<std::vector<wchar_t>>)->Arg(1)->Arg(16384)->Arg(1048576);
+BENCHMARK(BM_format_to_n_string_back_inserter<std::list<wchar_t>>)->Arg(1)->Arg(16384)->Arg(1048576);
+BENCHMARK(BM_format_to_n_string_begin<std::wstring>)->Arg(1)->Arg(16384)->Arg(1048576);
+BENCHMARK(BM_format_to_n_string_begin<std::vector<wchar_t>>)->Arg(1)->Arg(16384)->Arg(1048576);
+BENCHMARK(BM_format_to_n_string_begin<std::list<wchar_t>>)->Arg(1)->Arg(16384)->Arg(1048576);
+BENCHMARK(BM_format_to_n_string_span<wchar_t>)->Arg(1)->Arg(16384)->Arg(1048576);
+BENCHMARK(BM_format_to_n_string_pointer<wchar_t>)->Arg(1)->Arg(16384)->Arg(1048576);
#endif
BENCHMARK_MAIN();
diff --git a/libcxx/test/benchmarks/format/formatted_size.bench.cpp b/libcxx/test/benchmarks/format/formatted_size.bench.cpp
index e244f0bbb8cb2..9c52f386a782a 100644
--- a/libcxx/test/benchmarks/format/formatted_size.bench.cpp
+++ b/libcxx/test/benchmarks/format/formatted_size.bench.cpp
@@ -28,9 +28,9 @@ static void BM_formatted_size_string(benchmark::State& state) {
state.SetBytesProcessed(state.iterations() * size * sizeof(CharT));
}
-BENCHMARK(BM_formatted_size_string<char>)->RangeMultiplier(2)->Range(1, 1 << 20);
+BENCHMARK(BM_formatted_size_string<char>)->Arg(1)->Arg(16384)->Arg(1048576);
#ifndef TEST_HAS_NO_WIDE_CHARACTERS
-BENCHMARK(BM_formatted_size_string<wchar_t>)->RangeMultiplier(2)->Range(1, 1 << 20);
+BENCHMARK(BM_formatted_size_string<wchar_t>)->Arg(1)->Arg(16384)->Arg(1048576);
#endif
BENCHMARK_MAIN();
More information about the libcxx-commits
mailing list