[libcxx-commits] [libcxx] [libc++] Add benchmarks to the associative containers that don't go to the end of the container (PR #175005)
Nikolas Klauser via libcxx-commits
libcxx-commits at lists.llvm.org
Tue Jan 13 06:43:44 PST 2026
================
@@ -340,11 +351,20 @@ void associative_container_benchmarks(std::string container) {
}
});
- bench("insert_or_assign(key, value) (new value)", [=](auto& st) {
+ auto insert_or_assign_bench = [=](bool bench_end_iter, auto& st) {
const std::size_t size = st.range(0);
std::vector<Value> in = make_value_types(generate_unique_keys(size + 1));
- Value to_insert = in.back();
- in.pop_back();
+ auto skipped_val = bench_end_iter ? in.size() - 1 : in.size() / 2;
+ Value to_insert = in[skipped_val];
+ { // Remove the element
+ std::vector<Value> tmp;
+ tmp.reserve(in.size() - 1);
+ for (size_t i = 0; i != in.size(); ++i)
+ if (i != skipped_val)
+ tmp.emplace_back(in[i]);
+ in = std::move(tmp);
+ }
----------------
philnik777 wrote:
That doesn't work because our elements aren't always Cpp17MoveAssignable. Same below.
https://github.com/llvm/llvm-project/pull/175005
More information about the libcxx-commits
mailing list