[libcxx-commits] [libcxx] [libc++] added benchmarks for `string::append()` (PR #213990)

Nikolas Klauser via libcxx-commits libcxx-commits at lists.llvm.org
Fri Aug 7 00:20:22 PDT 2026


================
@@ -498,6 +517,42 @@ int main(int argc, char** argv) {
           [](auto bm) { bm->Arg(large_size); }); // for naming
   }
 
+  {
+    static auto bench_impl =
+        []<size_t size, bool opaque, class CharT>(
+            std::integral_constant<size_t, size>,
+            std::bool_constant<opaque>,
+            std::type_identity<CharT>,
+            benchmark::State& state) {
+          std::basic_string<CharT> src(size, 'a');
+          std::basic_string<CharT> string = src;
+          for (auto _ : state) {
+            benchmark::DoNotOptimize(string);
+            string.clear();
+            if constexpr (opaque)
+              benchmark::DoNotOptimize(src);
----------------
philnik777 wrote:

Why do we care about opaqueness here? `unoptimizable_forward_iterator` already tries to be opaque; I don't think we need another layer. If we remove that we can also instantiate the lambda with a dynamic size instead.

https://github.com/llvm/llvm-project/pull/213990


More information about the libcxx-commits mailing list