summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--absl/container/internal/raw_hash_set_benchmark.cc38
1 files changed, 26 insertions, 12 deletions
diff --git a/absl/container/internal/raw_hash_set_benchmark.cc b/absl/container/internal/raw_hash_set_benchmark.cc
index a9b52c4f..88b07373 100644
--- a/absl/container/internal/raw_hash_set_benchmark.cc
+++ b/absl/container/internal/raw_hash_set_benchmark.cc
@@ -387,28 +387,42 @@ void BM_NoOpReserveStringTable(benchmark::State& state) {
BENCHMARK(BM_NoOpReserveStringTable);
void BM_ReserveIntTable(benchmark::State& state) {
- int reserve_size = state.range(0);
- for (auto _ : state) {
+ constexpr size_t kBatchSize = 1024;
+ size_t reserve_size = static_cast<size_t>(state.range(0));
+
+ std::vector<IntTable> tables;
+ while (state.KeepRunningBatch(kBatchSize)) {
state.PauseTiming();
- IntTable t;
+ tables.clear();
+ tables.resize(kBatchSize);
state.ResumeTiming();
- benchmark::DoNotOptimize(t);
- t.reserve(reserve_size);
+ for (auto& t : tables) {
+ benchmark::DoNotOptimize(t);
+ t.reserve(reserve_size);
+ benchmark::DoNotOptimize(t);
+ }
}
}
-BENCHMARK(BM_ReserveIntTable)->Range(128, 4096);
+BENCHMARK(BM_ReserveIntTable)->Range(1, 64);
void BM_ReserveStringTable(benchmark::State& state) {
- int reserve_size = state.range(0);
- for (auto _ : state) {
+ constexpr size_t kBatchSize = 1024;
+ size_t reserve_size = static_cast<size_t>(state.range(0));
+
+ std::vector<StringTable> tables;
+ while (state.KeepRunningBatch(kBatchSize)) {
state.PauseTiming();
- StringTable t;
+ tables.clear();
+ tables.resize(kBatchSize);
state.ResumeTiming();
- benchmark::DoNotOptimize(t);
- t.reserve(reserve_size);
+ for (auto& t : tables) {
+ benchmark::DoNotOptimize(t);
+ t.reserve(reserve_size);
+ benchmark::DoNotOptimize(t);
+ }
}
}
-BENCHMARK(BM_ReserveStringTable)->Range(128, 4096);
+BENCHMARK(BM_ReserveStringTable)->Range(1, 64);
// Like std::iota, except that ctrl_t doesn't support operator++.
template <typename CtrlIter>