X-Git-Url: http://plrg.eecs.uci.edu/git/?a=blobdiff_plain;f=folly%2FBenchmark.cpp;h=b09faf2eec011697634d3fb4e2d6a34a12d77635;hb=d2c8a36b6b96eea44e9e92fa6946d607f8530b07;hp=1b32e9ef3c479f7b81b6a20f923c801ddd589be5;hpb=321542683a01c3f334047531e9b487f047129775;p=folly.git diff --git a/folly/Benchmark.cpp b/folly/Benchmark.cpp index 1b32e9ef..b09faf2e 100644 --- a/folly/Benchmark.cpp +++ b/folly/Benchmark.cpp @@ -35,18 +35,30 @@ using namespace std; DEFINE_bool(benchmark, false, "Run benchmarks."); DEFINE_bool(json, false, "Output in JSON format."); -DEFINE_string(bm_regex, "", - "Only benchmarks whose names match this regex will be run."); - -DEFINE_int64(bm_min_usec, 100, - "Minimum # of microseconds we'll accept for each benchmark."); - -DEFINE_int64(bm_min_iters, 1, - "Minimum # of iterations we'll try for each benchmark."); - -DEFINE_int32(bm_max_secs, 1, - "Maximum # of seconds we'll spend on each benchmark."); - +DEFINE_string( + bm_regex, + "", + "Only benchmarks whose names match this regex will be run."); + +DEFINE_int64( + bm_min_usec, + 100, + "Minimum # of microseconds we'll accept for each benchmark."); + +DEFINE_int64( + bm_min_iters, + 1, + "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( + bm_max_secs, + 1, + "Maximum # of seconds we'll spend on each benchmark."); namespace folly { @@ -229,7 +241,7 @@ static double runBenchmarkGetNSPerIteration(const BenchmarkFun& fun, static uint64_t resolutionInNs = 0; if (!resolutionInNs) { timespec ts; - CHECK_EQ(0, clock_getres(detail::DEFAULT_CLOCK_ID, &ts)); + CHECK_EQ(0, clock_getres(CLOCK_REALTIME, &ts)); CHECK_EQ(0, ts.tv_sec) << "Clock sucks."; CHECK_LT(0, ts.tv_nsec) << "Clock too fast for its own good."; CHECK_EQ(1, ts.tv_nsec) << "Clock too coarse, upgrade your kernel."; @@ -255,7 +267,8 @@ static double runBenchmarkGetNSPerIteration(const BenchmarkFun& fun, size_t actualEpochs = 0; 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); if (nsecsAndIter.first < minNanoseconds) { continue;