[libcxx-commits] [libcxx] 69685bb - [libc++] Actually partially populate the container in a benchmark (#213146)

via libcxx-commits libcxx-commits at lists.llvm.org
Fri Jul 31 10:20:19 PDT 2026


Author: Louis Dionne
Date: 2026-07-31T13:20:14-04:00
New Revision: 69685bb9ce2dc1976b9f4f852caaebdfd98485d1

URL: https://github.com/llvm/llvm-project/commit/69685bb9ce2dc1976b9f4f852caaebdfd98485d1
DIFF: https://github.com/llvm/llvm-project/commit/69685bb9ce2dc1976b9f4f852caaebdfd98485d1.diff

LOG: [libc++] Actually partially populate the container in a benchmark (#213146)

The "partially populated" variant of assignment was a copy-paste of the
"into cleared container" assignment.

Added: 
    

Modified: 
    libcxx/test/benchmarks/containers/associative/associative_container_benchmarks.h

Removed: 
    


################################################################################
diff  --git a/libcxx/test/benchmarks/containers/associative/associative_container_benchmarks.h b/libcxx/test/benchmarks/containers/associative/associative_container_benchmarks.h
index a55f187d2ac80..b45ef28075177 100644
--- a/libcxx/test/benchmarks/containers/associative/associative_container_benchmarks.h
+++ b/libcxx/test/benchmarks/containers/associative/associative_container_benchmarks.h
@@ -238,7 +238,12 @@ void associative_container_benchmarks(std::string container) {
     const std::size_t size = st.range(0);
     std::vector<Value> in  = make_value_types(generate_unique_keys(size));
     Container src(in.begin(), in.end());
+    Container half(std::next(in.begin(), in.size() / 2), in.end());
+
     Container c[BatchSize];
+    for (std::size_t i = 0; i != BatchSize; ++i) {
+      c[i] = half;
+    }
 
     while (st.KeepRunningBatch(BatchSize)) {
       for (std::size_t i = 0; i != BatchSize; ++i) {
@@ -249,7 +254,7 @@ void associative_container_benchmarks(std::string container) {
 
       st.PauseTiming();
       for (std::size_t i = 0; i != BatchSize; ++i) {
-        c[i].clear();
+        c[i] = half;
       }
       st.ResumeTiming();
     }


        


More information about the libcxx-commits mailing list