[libcxx-commits] [libcxx] [libc++] Speed up vector<bool> copy/move-ctors [1/3] (PR #120132)
Louis Dionne via libcxx-commits
libcxx-commits at lists.llvm.org
Mon Jan 20 08:55:41 PST 2025
================
@@ -39,6 +39,36 @@ void BM_CopyConstruct(benchmark::State& st, Container) {
}
}
+template <class Container>
+void BM_MoveConstruct(benchmark::State& st, Container) {
+ auto size = st.range(0);
+ Container c(size);
+ for (auto _ : st) {
+ auto v = std::move(c);
----------------
ldionne wrote:
This benchmark has the issue that it only moves from a non-empty vector the first time around. After the first iteration, it is moving from a moved-from vector.
There's also the cost of destruction inside this benchmark, which may or may not add too much noise.
Since your patch doesn't actually change the move constructor (and the move constructor is close to trivial), I don't think you need this benchmark as part of this patch at all. I would suggest removing it.
https://github.com/llvm/llvm-project/pull/120132
More information about the libcxx-commits
mailing list