[libcxx-commits] [libcxx] Optimize __assign_with_sentinel in std::vector (PR #113852)

Peng Liu via libcxx-commits libcxx-commits at lists.llvm.org
Thu Nov 7 12:35:42 PST 2024


================
@@ -1031,9 +1031,14 @@ template <class _Tp, class _Allocator>
 template <class _Iterator, class _Sentinel>
----------------
winner245 wrote:

We don't have benchmarks for `vector::assign(_InputIterator, _InputIterator)`, so I added the benchmark tests. My tests showed that performance of `assign(_InputIterator, _InputIterator)` for `std::vector<std::string>` is about 2.3x faster, and is slightly faster or the same for `std::vector<int>`. This is consistent with my prior tests. 

The following are screenshots of my local testing. 

- Benchmark test before applying this patch:
![before](https://github.com/user-attachments/assets/ceebd727-d640-4b1b-bc41-70845f0d133f)

- Benchmark test after applying this patch:
![after](https://github.com/user-attachments/assets/45b1903a-6b4b-4a75-be89-d91d3a62b97a)




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


More information about the libcxx-commits mailing list