Skip to content

Commit

Permalink
explains how folly benchmark decides how many iterations to run and h…
Browse files Browse the repository at this point in the history
…ow to tune it (#2348)

Summary:

I spent some time to figure this out and it should be beneficial to mention that in the doc

Differential Revision: D66708725
  • Loading branch information
Zhijian Jiang authored and facebook-github-bot committed Dec 3, 2024
1 parent 06c0c8d commit a484619
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions folly/docs/Benchmark.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,11 @@ about it. Sometimes the function itself would want to do that
iteration---for example how about inserting `n` elements instead of
100 elements? To do the iteration internally, use `BENCHMARK` with two
parameters. The second parameter is the number of iterations and is
passed by the framework down to the function. The type of the count is
implicitly `unsigned`. Consider a slightly reworked example:
passed by the framework down to the function (folly benchmark runs as many as
iterations until the time spent exceeds 0.1ms ([code pointer](https://github.com/facebook/folly/blob/main/folly/Benchmark.cpp#L196)).
To increase iterations, especially for high-latency methods, adjust the `bm_min_usec` flag ([code pointer](https://github.com/facebook/folly/blob/main/folly/Benchmark.cpp#L179))
and `bm_max_secs` flag([code pointer](https://github.com/facebook/folly/blob/main/folly/Benchmark.cpp#L106))) to allow higher time budget).
The type of the count is implicitly `unsigned`. Consider a slightly reworked example:
``` Cpp
#include <folly/Benchmark.h>
Expand Down

0 comments on commit a484619

Please sign in to comment.