aboutsummaryrefslogtreecommitdiff
path: root/include/benchmark
diff options
context:
space:
mode:
authorEric Fiselier <eric@efcs.ca>2015-03-26 23:37:26 -0400
committerEric Fiselier <eric@efcs.ca>2015-03-26 23:37:26 -0400
commit4bf6ceb50dcebe08afb10670a9e0c9c077a6305a (patch)
tree0d1a2a60acc998826307936162826ccc6dda05eb /include/benchmark
parent8b0b73f06c615f2712e69e0d4ea1a356b8b7a445 (diff)
downloadgoogle-benchmark-4bf6ceb50dcebe08afb10670a9e0c9c077a6305a.tar.gz
Change the available benchmark options
Diffstat (limited to 'include/benchmark')
-rw-r--r--include/benchmark/benchmark_api.h27
1 files changed, 19 insertions, 8 deletions
diff --git a/include/benchmark/benchmark_api.h b/include/benchmark/benchmark_api.h
index 0982e93..aa3ee99 100644
--- a/include/benchmark/benchmark_api.h
+++ b/include/benchmark/benchmark_api.h
@@ -113,6 +113,14 @@ template <class Q> int BM_Sequential(benchmark::State& state) {
}
BENCHMARK_TEMPLATE(BM_Sequential, WaitQueue<int>)->Range(1<<0, 1<<10);
+Use `Benchmark::MinTime(double t)` to set the minimum time used to run the
+benchmark. This option overrides the `benchmark_min_time` flag.
+
+void BM_test(benchmark::State& state) {
+ ... body ...
+}
+BENCHMARK(BM_test)->MinTime(2.0); // Run for at least 2 seconds.
+
In a multithreaded test, it is guaranteed that none of the threads will start
until all have called KeepRunning, and all will have finished before KeepRunning
returns false. As such, any global setup or teardown you want to do can be
@@ -228,14 +236,6 @@ public:
// within each benchmark iteration, if possible.
void ResumeTiming();
- // If a particular benchmark is I/O bound, or if for some reason CPU
- // timings are not representative, call this method from within the
- // benchmark routine. If called, the elapsed time will be used to
- // control how many iterations are run, and in the printing of
- // items/second or MB/seconds values. If not called, the cpu time
- // used by the benchmark will be used.
- void UseRealTime();
-
// Set the number of bytes processed by the current benchmark
// execution. This routine is typically called once at the end of a
// throughput oriented benchmark. If this routine is called with a
@@ -382,6 +382,17 @@ class Benchmark {
// Threads, etc.
Benchmark* Apply(void (*func)(Benchmark* benchmark));
+ // Set the minimum amount of time to use when running this benchmark. This
+ // option overrides the `benchmark_min_time` flag.
+ Benchmark* MinTime(double t);
+
+ // If a particular benchmark is I/O bound, or if for some reason CPU
+ // timings are not representative, call this method. If called, the elapsed
+ // time will be used to control how many iterations are run, and in the
+ // printing of items/second or MB/seconds values. If not called, the cpu
+ // time used by the benchmark will be used.
+ Benchmark* UseRealTime();
+
// Support for running multiple copies of the same benchmark concurrently
// in multiple threads. This may be useful when measuring the scaling
// of some piece of code.