[libcxx-commits] [PATCH] D149827: [libc++][ranges] Implement the changes to `deque` from P1206 (`ranges::to`):

Konstantin Varlamov via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Tue May 16 00:07:40 PDT 2023


var-const marked 3 inline comments as done.
var-const added inline comments.


================
Comment at: libcxx/test/std/containers/sequences/deque/deque.cons/from_range.pass.cpp:1
+//===----------------------------------------------------------------------===//
+//
----------------
ldionne wrote:
> I think we should also add benchmarks in `libcxx/benchmarks/ContainerBenchmarks.h` for the new construction methods we're adding.
Done (also added for `vector`). This patch doesn't seem to make any difference for existing constructors (seems within fluctuation) and the difference between the `(iter, iter)` constructor and the `from_range` constructor also appears negligible as expected.

For completeness' sake, here are the results before this patch:
```
-----------------------------------------------------------------------------------
Benchmark                                         Time             CPU   Iterations
-----------------------------------------------------------------------------------
BM_ConstructSize/deque_byte/5140480          232868 ns       220132 ns         3163
BM_ConstructSizeValue/deque_byte/5140480     189452 ns       172314 ns         4026
BM_ConstructIterIter/deque_char/1024           79.0 ns         78.9 ns      9187075
BM_ConstructIterIter/deque_size_t/1024          300 ns          300 ns      2223959
BM_ConstructIterIter/deque_string/1024       107435 ns       107390 ns         6744
```
And with this patch:
```
-----------------------------------------------------------------------------------
Benchmark                                         Time             CPU   Iterations
-----------------------------------------------------------------------------------
BM_ConstructSize/deque_byte/5140480          231027 ns       219294 ns         3148
BM_ConstructSizeValue/deque_byte/5140480     176521 ns       170531 ns         4105
BM_ConstructIterIter/deque_char/1024           77.5 ns         76.0 ns      9186111
BM_ConstructIterIter/deque_size_t/1024          301 ns          301 ns      2327840
BM_ConstructIterIter/deque_string/1024       105603 ns       105535 ns         6881
BM_ConstructFromRange/deque_char/1024          74.3 ns         74.2 ns      9481112
BM_ConstructFromRange/deque_size_t/1024         301 ns          301 ns      2288232
BM_ConstructFromRange/deque_string/1024      100816 ns       100813 ns         6983
```

And also `vector` with this patch:
```
------------------------------------------------------------------------------------
Benchmark                                          Time             CPU   Iterations
------------------------------------------------------------------------------------
BM_ConstructSize/vector_byte/5140480          272017 ns       271861 ns         2394
BM_ConstructSizeValue/vector_byte/5140480     260968 ns       260866 ns         2566
BM_ConstructIterIter/vector_char/1024           39.5 ns         39.5 ns     17688158
BM_ConstructIterIter/vector_size_t/1024          139 ns          139 ns      5072096
BM_ConstructIterIter/vector_string/1024        94366 ns        94365 ns         7484
BM_ConstructFromRange/vector_char/1024          40.1 ns         40.1 ns     17496195
BM_ConstructFromRange/vector_size_t/1024         157 ns          148 ns      4767970
BM_ConstructFromRange/vector_string/1024      107067 ns       102741 ns         6937
```


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D149827/new/

https://reviews.llvm.org/D149827



More information about the libcxx-commits mailing list