Commit bae26019 by Abseil Team Committed by Copybara-Service

Add the `BM_EraseEmplace` benchmark that constantly adds and removes the same element.

PiperOrigin-RevId: 591987002
Change-Id: Ic1ed2063aeb95a6e814eefcbed024e1a5a1d8d2f
parent 8900d7c4
......@@ -14,6 +14,8 @@
#include <array>
#include <cmath>
#include <cstddef>
#include <cstdint>
#include <numeric>
#include <random>
#include <tuple>
......@@ -205,6 +207,22 @@ void CacheInSteadyStateArgs(Benchmark* bm) {
}
BENCHMARK(BM_CacheInSteadyState)->Apply(CacheInSteadyStateArgs);
void BM_EraseEmplace(benchmark::State& state) {
IntTable t;
int64_t size = state.range(0);
for (int64_t i = 0; i < size; ++i) {
t.emplace(i);
}
while (state.KeepRunningBatch(size)) {
for (int64_t i = 0; i < size; ++i) {
benchmark::DoNotOptimize(t);
t.erase(i);
t.emplace(i);
}
}
}
BENCHMARK(BM_EraseEmplace)->Arg(1)->Arg(2)->Arg(4)->Arg(8)->Arg(16)->Arg(100);
void BM_EndComparison(benchmark::State& state) {
StringTable t = {{"a", "a"}, {"b", "b"}};
auto it = t.begin();
......
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