From dd005911b955da49a11aa755acb9addc0c8a2a24 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Fri, 29 Apr 2022 12:23:53 -0600 Subject: [PATCH] [benchmark-set] Reduce lookup benchmark overhead Turnsout 90% was overhead... Now lookup is in the 4ns ballpark. --- perf/benchmark-set.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/perf/benchmark-set.cc b/perf/benchmark-set.cc index 64bc47039..022b9b003 100644 --- a/perf/benchmark-set.cc +++ b/perf/benchmark-set.cc @@ -82,9 +82,10 @@ static void BM_SetLookup(benchmark::State& state) { RandomSet(set_size, max_value, original); assert(hb_set_get_population(original) == set_size); + auto needle = max_value / 2; for (auto _ : state) { benchmark::DoNotOptimize( - hb_set_has (original, rand() % max_value)); + hb_set_has (original, needle)); } hb_set_destroy(original);