Commit b559abcb by Abseil Team Committed by Copybara-Service

Create and destroy tables outside of the timer and in batch in Reserve benchmarks.

PiperOrigin-RevId: 592483250
Change-Id: I55fa9982c4dbc723b30957cb31da95251e368707
parent 1ae12074
......@@ -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();
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();
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>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment