From 5f43ce825afbedb1edbbc6610d1c017aa0f5fe27 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Fri, 29 Apr 2022 13:37:46 -0600 Subject: [PATCH] [benchmark-set] Split SetLookup into an ordered and random version --- perf/benchmark-set.cc | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/perf/benchmark-set.cc b/perf/benchmark-set.cc index 82266486d..547d69cdf 100644 --- a/perf/benchmark-set.cc +++ b/perf/benchmark-set.cc @@ -74,7 +74,7 @@ BENCHMARK(BM_SetOrderedInsert_1000) {2, 512}}); // Density /* Single value lookup on sets of various sizes. */ -static void BM_SetLookup(benchmark::State& state) { +static void BM_SetLookup(benchmark::State& state, unsigned interval) { unsigned set_size = state.range(0); unsigned max_value = state.range(0) * state.range(1); @@ -85,12 +85,16 @@ static void BM_SetLookup(benchmark::State& state) { auto needle = max_value / 2; for (auto _ : state) { benchmark::DoNotOptimize( - hb_set_has (original, needle++ % max_value)); + hb_set_has (original, (needle += interval) % max_value)); } hb_set_destroy(original); } -BENCHMARK(BM_SetLookup) +BENCHMARK_CAPTURE(BM_SetLookup, ordered, 3) + ->Ranges( + {{1 << 10, 1 << 16}, // Set Size + {2, 512}}); // Density +BENCHMARK_CAPTURE(BM_SetLookup, random, 12345) ->Ranges( {{1 << 10, 1 << 16}, // Set Size {2, 512}}); // Density