Add support for returning number of benchmark iterations
authorMarcus Holland-Moritz <mhx@fb.com>
Fri, 6 Jun 2014 22:57:21 +0000 (15:57 -0700)
committerAnton Likhtarov <alikhtarov@fb.com>
Mon, 9 Jun 2014 22:36:00 +0000 (15:36 -0700)
commitaed6ef6fd357f48e0ebe9025d12021f73b00f812
tree9a6396fec941c3cd8eba596a2601fc18ec08c447
parentec08f7d45a7b0b9a23fdccaf542e7cbfadf7e67c
Add support for returning number of benchmark iterations

Summary:
I'm looping through a large number of test cases in a benchmark and I'm
interested in the average time per test case rather than the total time,
which is what I'm currently seeing. In order to get the average time,
I need to be able to tell the benchmark module how many iterations have
been run.

This change adds _MULTI variants of the different BENCHMARK_ macros that
allow for returning the actual number of iterations that have been run,
e.g.:

BENCHMARK_MULTI(benchmarkSomething) {
std::vector<int> testCases { 0, 1, 1, 2, 3, 5 };
for (int c : testCases) {
doSomething(c);
}
return testCases.size();
}

Test Plan:
* fbconfig -r folly && fbmake runtests
* added new test cases to example benchmark code

Reviewed By: simpkins@fb.com

Subscribers: folly@lists, london_search@

FB internal diff: D1356437
folly/Benchmark.cpp
folly/Benchmark.h
folly/gen/test/Bench.h
folly/test/BenchmarkTest.cpp