summaryrefslogtreecommitdiff
path: root/absl/container/internal/raw_hash_set_benchmark.cc
diff options
context:
space:
mode:
authorGravatar Abseil Team <absl-team@google.com>2021-06-23 09:44:41 -0700
committerGravatar rogeeff <rogeeff@google.com>2021-06-24 11:32:25 -0400
commita2419e63b8ae3b924152822f3c9f9da67ff6e215 (patch)
tree7a2f329a5baad755f80c78c21ee61d439fb76373 /absl/container/internal/raw_hash_set_benchmark.cc
parent4a23151e7ee089f54f0575f0a6d499e3a3fb6728 (diff)
Export of internal Abseil changes
-- 2684e80d877b688b8d9e0af1b7acddbadc973152 by Evan Brown <ezb@google.com>: Add an insert codegen function for raw_hash_set_benchmark. PiperOrigin-RevId: 381052237 -- 8394ef3071714a41484cb5b271cba0611d954a7a by Abseil Team <absl-team@google.com>: Optimize raw_hash_set ctor for random-access iterators PiperOrigin-RevId: 380832215 GitOrigin-RevId: 2684e80d877b688b8d9e0af1b7acddbadc973152 Change-Id: Icf7929fdfab50a1b26f3dc5505575363b4f5838d
Diffstat (limited to 'absl/container/internal/raw_hash_set_benchmark.cc')
-rw-r--r--absl/container/internal/raw_hash_set_benchmark.cc24
1 files changed, 24 insertions, 0 deletions
diff --git a/absl/container/internal/raw_hash_set_benchmark.cc b/absl/container/internal/raw_hash_set_benchmark.cc
index f9be2c5a..977ff4c0 100644
--- a/absl/container/internal/raw_hash_set_benchmark.cc
+++ b/absl/container/internal/raw_hash_set_benchmark.cc
@@ -254,6 +254,23 @@ void BM_CopyAssign(benchmark::State& state) {
}
BENCHMARK(BM_CopyAssign)->Range(128, 4096);
+void BM_RangeCtor(benchmark::State& state) {
+ std::random_device rd;
+ std::mt19937 rng(rd());
+ std::uniform_int_distribution<uint64_t> dist(0, ~uint64_t{});
+ std::vector<int> values;
+ const size_t desired_size = state.range(0);
+ while (values.size() < desired_size) {
+ values.emplace_back(dist(rng));
+ }
+
+ for (auto unused : state) {
+ IntTable t{values.begin(), values.end()};
+ benchmark::DoNotOptimize(t);
+ }
+}
+BENCHMARK(BM_RangeCtor)->Range(128, 65536);
+
void BM_NoOpReserveIntTable(benchmark::State& state) {
IntTable t;
t.reserve(100000);
@@ -378,6 +395,12 @@ bool CodegenAbslRawHashSetInt64FindNeEnd(
return table->find(key) != table->end();
}
+auto CodegenAbslRawHashSetInt64Insert(absl::container_internal::IntTable* table,
+ int64_t key)
+ -> decltype(table->insert(key)) {
+ return table->insert(key);
+}
+
bool CodegenAbslRawHashSetInt64Contains(
absl::container_internal::IntTable* table, int64_t key) {
return table->contains(key);
@@ -391,6 +414,7 @@ void CodegenAbslRawHashSetInt64Iterate(
int odr =
(::benchmark::DoNotOptimize(std::make_tuple(
&CodegenAbslRawHashSetInt64Find, &CodegenAbslRawHashSetInt64FindNeEnd,
+ &CodegenAbslRawHashSetInt64Insert,
&CodegenAbslRawHashSetInt64Contains,
&CodegenAbslRawHashSetInt64Iterate)),
1);