Skip to content

Commit

Permalink
Benchmark should not print zeros if min_iters >= max_iters
Browse files Browse the repository at this point in the history
Summary:
Prior to this fix, this benchmark, which internally sets `bm_max_iters` would print out zero timings when `bm_min_iters` was too high:

```
buck2 run @//mode/opt //folly/test:atomic_hash_map_test -- \
  --gtest_filter=X --benchmark=1 --bm_regex=.*_miss --bm_min_iters=1000000
```

Reviewed By: nickbrekhus

Differential Revision: D57396861

fbshipit-source-id: c0b8318be2e572563715197f6546441f57962961
  • Loading branch information
Alexey Spiridonov authored and facebook-github-bot committed May 16, 2024
1 parent 0b3d2ce commit 021cb16
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions folly/Benchmark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -899,6 +899,12 @@ void runBenchmarks() {
"WARNING: Running with constant number of iterations. Results might be jittery.\n");
}

if (FLAGS_bm_min_iters >= FLAGS_bm_max_iters) {
std::cerr << "WARNING: bm_min_iters > bm_max_iters; increasing the max"
<< std::endl;
FLAGS_bm_max_iters = FLAGS_bm_min_iters + 1;
}

checkRunMode();

auto& state = detail::globalBenchmarkState();
Expand Down

0 comments on commit 021cb16

Please sign in to comment.