From 7072c544b52774ac5a22835121e8e2747ad61158 Mon Sep 17 00:00:00 2001 From: Gavin Andresen Date: Tue, 29 Sep 2015 17:17:24 -0400 Subject: Support very-fast-running benchmarks Avoid calling gettimeofday every time through the benchmarking loop, by keeping track of how long each loop takes and doubling the number of iterations done between time checks when they take less than 1/16'th of the total elapsed time. --- src/bench/bench.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/bench/bench.h') diff --git a/src/bench/bench.h b/src/bench/bench.h index fee9b8c38d..bf591a2be6 100644 --- a/src/bench/bench.h +++ b/src/bench/bench.h @@ -41,10 +41,12 @@ namespace benchmark { double beginTime; double lastTime, minTime, maxTime; int64_t count; + int64_t timeCheckCount; public: State(std::string _name, double _maxElapsed) : name(_name), maxElapsed(_maxElapsed), count(0) { minTime = std::numeric_limits::max(); maxTime = std::numeric_limits::min(); + timeCheckCount = 1; } bool KeepRunning(); }; -- cgit v1.2.3