-
Notifications
You must be signed in to change notification settings - Fork 15.1k
Optimize vector::assign for InputIterator-only pair inputs #113852
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
a7aa7c5
75eab99
c131b5c
52121af
08abdb1
c9c6fb9
91eb3be
4fa53ef
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,8 +14,9 @@ | |
| #include <iterator> | ||
| #include <utility> | ||
|
|
||
| #include "Utilities.h" | ||
| #include "benchmark/benchmark.h" | ||
| #include "Utilities.h" | ||
| #include "test_iterators.h" | ||
|
|
||
| namespace ContainerBenchmarks { | ||
|
|
||
|
|
@@ -50,6 +51,19 @@ void BM_Assignment(benchmark::State& st, Container) { | |
| } | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not attached to this line: Can you please add a release note to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thank you for your positive feedback and recognition of my work! I appreciate your time and effort in reviewing this PR. I have added a description of this performance optimization to the release notes and rebased the PR onto the main branch. Thanks again for your help and support! |
||
| } | ||
|
|
||
| template <std::size_t... sz, typename Container, typename GenInputs> | ||
| void BM_AssignInputIterIter(benchmark::State& st, Container c, GenInputs gen) { | ||
| auto v = gen(1, sz...); | ||
| c.resize(st.range(0), v[0]); | ||
| auto in = gen(st.range(1), sz...); | ||
| benchmark::DoNotOptimize(&in); | ||
| benchmark::DoNotOptimize(&c); | ||
| for (auto _ : st) { | ||
| c.assign(cpp17_input_iterator(in.begin()), cpp17_input_iterator(in.end())); | ||
| benchmark::ClobberMemory(); | ||
| } | ||
| } | ||
|
|
||
| template <class Container> | ||
| void BM_ConstructSizeValue(benchmark::State& st, Container, typename Container::value_type const& val) { | ||
| const auto size = st.range(0); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.