Commit 46afd8e6 by Eric Fiselier

Don't limit benchmarks with manual timers to 5x the elapsed real time.

When using CPU time to determine the correct number of iterations the library additionally checks if the benchmark has consumed 5x the minimum required time according to the wall clock. This prevents benchmarks with low CPU usage from running for much longer than actually intended. However when a benchmark uses a manual timer this heuristic isn't helpful and likely isn't correct since we don't know what the manual timer actually measures. This patch removes the above restriction when a benchmark specifies a manual timer.
parent 74b24058
...@@ -296,7 +296,7 @@ std::vector<BenchmarkReporter::Run> RunBenchmark( ...@@ -296,7 +296,7 @@ std::vector<BenchmarkReporter::Run> RunBenchmark(
(b.report_mode == internal::RM_Unspecified (b.report_mode == internal::RM_Unspecified
? FLAGS_benchmark_report_aggregates_only ? FLAGS_benchmark_report_aggregates_only
: b.report_mode == internal::RM_ReportAggregatesOnly); : b.report_mode == internal::RM_ReportAggregatesOnly);
for (int i = 0; i < repeats; i++) { for (int repetition_num = 0; repetition_num < repeats; repetition_num++) {
for (;;) { for (;;) {
// Try benchmark // Try benchmark
VLOG(2) << "Running " << b.name << " for " << iters << "\n"; VLOG(2) << "Running " << b.name << " for " << iters << "\n";
...@@ -332,11 +332,20 @@ std::vector<BenchmarkReporter::Run> RunBenchmark( ...@@ -332,11 +332,20 @@ std::vector<BenchmarkReporter::Run> RunBenchmark(
const double min_time = const double min_time =
!IsZero(b.min_time) ? b.min_time : FLAGS_benchmark_min_time; !IsZero(b.min_time) ? b.min_time : FLAGS_benchmark_min_time;
// If this was the first run, was elapsed time or cpu time large enough?
// If this is not the first run, go with the current value of iter. // Determine if this run should be reported; Either it has
if ((i > 0) || has_explicit_iteration_count || results.has_error_ || // run for a sufficient amount of time or because an error was reported.
(iters >= kMaxIterations) || const bool should_report = repetition_num > 0
(seconds >= min_time) || (results.real_time_used >= 5 * min_time)) { || has_explicit_iteration_count // An exact iteration count was requested
|| results.has_error_
|| iters >= kMaxIterations
|| seconds >= min_time // the elapsed time is large enough
// CPU time is specified but the elapsed real time greatly exceeds the
// minimum time. Note that user provided timers are except from this
// sanity check.
|| ((results.real_time_used >= 5 * min_time) && !b.use_manual_time);
if (should_report) {
BenchmarkReporter::Run report = BenchmarkReporter::Run report =
CreateRunReport(b, results, iters, seconds); CreateRunReport(b, results, iters, seconds);
if (!report.error_occurred && b.complexity != oNone) if (!report.error_occurred && b.complexity != oNone)
......
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