pull/10122/head
Craig Tiller 8 years ago
parent 09acb108b7
commit ff23f801c5
  1. 7
      test/cpp/microbenchmarks/bm_arena.cc

@ -48,8 +48,15 @@ BENCHMARK(BM_Arena_NoOp)->Range(1, 1024 * 1024);
static void BM_Arena_ManyAlloc(benchmark::State& state) { static void BM_Arena_ManyAlloc(benchmark::State& state) {
gpr_arena* a = gpr_arena_create(state.range(0)); gpr_arena* a = gpr_arena_create(state.range(0));
const size_t realloc_after =
1024 * 1024 * 1024 / ((state.range(1) + 15) & 0xffffff0u);
while (state.KeepRunning()) { while (state.KeepRunning()) {
gpr_arena_alloc(a, state.range(1)); gpr_arena_alloc(a, state.range(1));
// periodically recreate arena to avoid OOM
if (state.iterations() % realloc_after == 0) {
gpr_arena_destroy(a);
a = gpr_arena_create(state.range(0));
}
} }
gpr_arena_destroy(a); gpr_arena_destroy(a);
} }

Loading…
Cancel
Save