Commit 0a3dae9d authored by Yinghai Lu's avatar Yinghai Lu Committed by Facebook Github Bot

Limit maximum number of iterations in folly::Benchmark with bm_max_iters

Summary:
We are using `bm_max_iters` in folly and other part of the code in fbcode but it didn't really exist in Benchmark.cpp. For example: https://github.com/facebook/folly/blob/master/folly/test/function_benchmark/main.cpp#L29

This patch adds back this functionality.

This diff depends on D3990600.

Reviewed By: yfeldblum

Differential Revision: D3989499

fbshipit-source-id: d2303b2bebb196e84a592d54a72af68171971491
parent 2acfd4d0
...@@ -50,6 +50,11 @@ DEFINE_int64( ...@@ -50,6 +50,11 @@ DEFINE_int64(
1, 1,
"Minimum # of iterations we'll try for each benchmark."); "Minimum # of iterations we'll try for each benchmark.");
DEFINE_int64(
bm_max_iters,
1L << 30L,
"Maximum # of iterations we'll try for each benchmark.");
DEFINE_int32( DEFINE_int32(
bm_max_secs, bm_max_secs,
1, 1,
...@@ -262,7 +267,8 @@ static double runBenchmarkGetNSPerIteration(const BenchmarkFun& fun, ...@@ -262,7 +267,8 @@ static double runBenchmarkGetNSPerIteration(const BenchmarkFun& fun,
size_t actualEpochs = 0; size_t actualEpochs = 0;
for (; actualEpochs < epochs; ++actualEpochs) { for (; actualEpochs < epochs; ++actualEpochs) {
for (unsigned int n = FLAGS_bm_min_iters; n < (1UL << 30); n *= 2) { const auto maxIters = FLAGS_bm_max_iters;
for (unsigned int n = FLAGS_bm_min_iters; n < maxIters; n *= 2) {
auto const nsecsAndIter = fun(n); auto const nsecsAndIter = fun(n);
if (nsecsAndIter.first < minNanoseconds) { if (nsecsAndIter.first < minNanoseconds) {
continue; continue;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment