diff options
Diffstat (limited to 'absl/container')
-rw-r--r-- | absl/container/btree_test.cc | 2 | ||||
-rw-r--r-- | absl/container/inlined_vector_benchmark.cc | 37 |
2 files changed, 22 insertions, 17 deletions
diff --git a/absl/container/btree_test.cc b/absl/container/btree_test.cc index a330cca32b90..3ac97f89a8b7 100644 --- a/absl/container/btree_test.cc +++ b/absl/container/btree_test.cc @@ -323,6 +323,7 @@ class unique_checker : public base_checker<TreeType, CheckerType> { unique_checker(const unique_checker &x) : super_type(x) {} template <class InputIterator> unique_checker(InputIterator b, InputIterator e) : super_type(b, e) {} + unique_checker& operator=(const unique_checker&) = default; // Insertion routines. std::pair<iterator, bool> insert(const value_type &x) { @@ -370,6 +371,7 @@ class multi_checker : public base_checker<TreeType, CheckerType> { multi_checker(const multi_checker &x) : super_type(x) {} template <class InputIterator> multi_checker(InputIterator b, InputIterator e) : super_type(b, e) {} + multi_checker& operator=(const multi_checker&) = default; // Insertion routines. iterator insert(const value_type &x) { diff --git a/absl/container/inlined_vector_benchmark.cc b/absl/container/inlined_vector_benchmark.cc index b99bbd62544f..3f2b4ed28a57 100644 --- a/absl/container/inlined_vector_benchmark.cc +++ b/absl/container/inlined_vector_benchmark.cc @@ -25,42 +25,45 @@ namespace { void BM_InlinedVectorFill(benchmark::State& state) { + const int len = state.range(0); absl::InlinedVector<int, 8> v; - int val = 10; + v.reserve(len); for (auto _ : state) { + v.resize(0); // Use resize(0) as InlinedVector releases storage on clear(). + for (int i = 0; i < len; ++i) { + v.push_back(i); + } benchmark::DoNotOptimize(v); - v.push_back(val); } } -BENCHMARK(BM_InlinedVectorFill)->Range(0, 1024); +BENCHMARK(BM_InlinedVectorFill)->Range(1, 256); void BM_InlinedVectorFillRange(benchmark::State& state) { const int len = state.range(0); - std::unique_ptr<int[]> ia(new int[len]); - for (int i = 0; i < len; i++) { - ia[i] = i; - } - auto* from = ia.get(); - auto* to = from + len; + const std::vector<int> src(len, len); + absl::InlinedVector<int, 8> v; + v.reserve(len); for (auto _ : state) { - benchmark::DoNotOptimize(from); - benchmark::DoNotOptimize(to); - absl::InlinedVector<int, 8> v(from, to); + benchmark::DoNotOptimize(src); + v.assign(src.begin(), src.end()); benchmark::DoNotOptimize(v); } } -BENCHMARK(BM_InlinedVectorFillRange)->Range(0, 1024); +BENCHMARK(BM_InlinedVectorFillRange)->Range(1, 256); void BM_StdVectorFill(benchmark::State& state) { + const int len = state.range(0); std::vector<int> v; - int val = 10; + v.reserve(len); for (auto _ : state) { + v.clear(); + for (int i = 0; i < len; ++i) { + v.push_back(i); + } benchmark::DoNotOptimize(v); - benchmark::DoNotOptimize(val); - v.push_back(val); } } -BENCHMARK(BM_StdVectorFill)->Range(0, 1024); +BENCHMARK(BM_StdVectorFill)->Range(1, 256); // The purpose of the next two benchmarks is to verify that // absl::InlinedVector is efficient when moving is more efficent than |