Skip to content

Commit d2a86fd

Browse files
andreas-abelcopybara-github
authored andcommitted
Add a warmup phase to the InsertMiss_Cold benchmarks.
The first iteration of the `for (uint32_t key : keys)` loop is about 100 times slower than the following iterations. Thus, the benchmark needs a long time to reach a steady state. By default, the benchmark framework runs each benchmark for around 0.5s. The first iteration of the loop seems to take around that much time. So sometimes, the benchmark framework runs just one iteration, and sometimes a significantly larger number of iterations (as the next iterations are much faster). This leads to a huge run-to-run variance. This CL adds a warmup phase to the benchmark that excludes the first iterations from the timing measurements. PiperOrigin-RevId: 744011324 Change-Id: I452a192ea5627eb5e9a9a078b7d123df1f443eaf
1 parent 77d4a36 commit d2a86fd

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

fleetbench/swissmap/cold_swissmap_benchmark.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,10 @@ static void FindMiss_Cold(benchmark::State& state) {
4545
static_cast<Density>(state.range(1)));
4646
auto& keys = sc.GetNonExistingKeys(sets);
4747

48+
int warmup = 5;
4849
while (true) {
4950
for (uint32_t key : keys) {
50-
if (!state.KeepRunningBatch(sets.size())) return;
51+
if (--warmup < 0 && !state.KeepRunningBatch(sets.size())) return;
5152
for (Set& set : sets) {
5253
DoNotOptimize(set);
5354
DoNotOptimize(key);

0 commit comments

Comments
 (0)