From fbd5fa1781ce6151770557a90d018f71e64e45d0 Mon Sep 17 00:00:00 2001 From: Vitaly Goldshteyn Date: Tue, 2 Apr 2024 12:20:51 -0700 Subject: Fix bug in BM_EraseIf. PiperOrigin-RevId: 621258501 Change-Id: Id094f3f0d0bc4a9fa8f3d1f90cfcd4c53beeb776 --- absl/container/internal/raw_hash_set_benchmark.cc | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'absl/container/internal/raw_hash_set_benchmark.cc') diff --git a/absl/container/internal/raw_hash_set_benchmark.cc b/absl/container/internal/raw_hash_set_benchmark.cc index 05f62d2f..424b72cf 100644 --- a/absl/container/internal/raw_hash_set_benchmark.cc +++ b/absl/container/internal/raw_hash_set_benchmark.cc @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -593,14 +594,17 @@ void BM_EraseIf(benchmark::State& state) { auto& table = tables.back(); for (int64_t i = 0; i < num_elements; i++) { // We use random keys to reduce noise. - k.push_back(absl::Uniform(rng, 0, ~int64_t{})); + k.push_back( + absl::Uniform(rng, 0, std::numeric_limits::max())); if (!table.insert(k.back()).second) { k.pop_back(); --i; // duplicated value, retrying } } std::sort(k.begin(), k.end()); - threshold.push_back(k[num_erased]); + threshold.push_back(static_cast(num_erased) < num_elements + ? k[num_erased] + : std::numeric_limits::max()); } while (state.KeepRunningBatch(static_cast(kRepetitions) * -- cgit v1.2.3