From d663b9b7236223b523d1271aaeea169f136feb52 Mon Sep 17 00:00:00 2001 From: Dominic Hamon Date: Thu, 12 Sep 2024 11:56:54 +0100 Subject: [PATCH] cleanups --- src/benchmark_runner.cc | 37 +++++++++++++++++-------------------- src/benchmark_runner.h | 14 +++----------- 2 files changed, 20 insertions(+), 31 deletions(-) diff --git a/src/benchmark_runner.cc b/src/benchmark_runner.cc index a59b16ba6..524f8a1ce 100644 --- a/src/benchmark_runner.cc +++ b/src/benchmark_runner.cc @@ -58,6 +58,14 @@ namespace benchmark { +BM_DECLARE_bool(benchmark_dry_run); +BM_DECLARE_string(benchmark_min_time); +BM_DECLARE_double(benchmark_min_warmup_time); +BM_DECLARE_int32(benchmark_repetitions); +BM_DECLARE_bool(benchmark_report_aggregates_only); +BM_DECLARE_bool(benchmark_display_aggregates_only); +BM_DECLARE_string(benchmark_perf_counters); + namespace internal { MemoryManager* memory_manager = nullptr; @@ -228,32 +236,21 @@ BenchmarkRunner::BenchmarkRunner( : b(b_), reports_for_family(reports_for_family_), parsed_benchtime_flag(ParseBenchMinTime(FLAGS_benchmark_min_time)), + min_time(FLAGS_benchmark_dry_run ? 0 : ComputeMinTime(b_, parsed_benchtime_flag)), + min_warmup_time(FLAGS_benchmark_dry_run ? 0 : ((!IsZero(b.min_time()) && b.min_warmup_time() > 0.0) + ? b.min_warmup_time() + : FLAGS_benchmark_min_warmup_time)), + warmup_done(FLAGS_benchmark_dry_run ? true : !(min_warmup_time > 0.0)), + repeats(FLAGS_benchmark_dry_run ? 1 : (b.repetitions() != 0 ? b.repetitions() + : FLAGS_benchmark_repetitions)), has_explicit_iteration_count(b.iterations() != 0 || parsed_benchtime_flag.tag == BenchTimeType::ITERS), pool(static_cast(b.threads() - 1)), - iters(has_explicit_iteration_count + iters(FLAGS_benchmark_dry_run ? 1 : (has_explicit_iteration_count ? ComputeIters(b_, parsed_benchtime_flag) - : 1), + : 1)), perf_counters_measurement_ptr(pcm_) { - if (FLAGS_benchmark_dry_run) { - min_time = 0; - min_warmup_time = 0; - warmup_done = true; - repeats = 1; - iters = 1; - } else { - min_time = ComputeMinTime(b_, parsed_benchtime_flag); - min_warmup_time = ((!IsZero(b.min_time()) && b.min_warmup_time() > 0.0) - ? b.min_warmup_time() - : FLAGS_benchmark_min_warmup_time); - warmup_done = !(min_warmup_time > 0.0); - repeats = - b.repetitions() != 0 ? b.repetitions() : FLAGS_benchmark_repetitions; - iters = has_explicit_iteration_count - ? ComputeIters(b_, parsed_benchtime_flag) - : 1; - } run_results.display_report_aggregates_only = (FLAGS_benchmark_report_aggregates_only || FLAGS_benchmark_display_aggregates_only); diff --git a/src/benchmark_runner.h b/src/benchmark_runner.h index 10bc51386..6e5ceb31e 100644 --- a/src/benchmark_runner.h +++ b/src/benchmark_runner.h @@ -25,14 +25,6 @@ namespace benchmark { -BM_DECLARE_string(benchmark_min_time); -BM_DECLARE_double(benchmark_min_warmup_time); -BM_DECLARE_int32(benchmark_repetitions); -BM_DECLARE_bool(benchmark_dry_run); -BM_DECLARE_bool(benchmark_report_aggregates_only); -BM_DECLARE_bool(benchmark_display_aggregates_only); -BM_DECLARE_string(benchmark_perf_counters); - namespace internal { extern MemoryManager* memory_manager; @@ -90,10 +82,10 @@ class BenchmarkRunner { BenchmarkReporter::PerFamilyRunReports* reports_for_family; BenchTimeType parsed_benchtime_flag; - double min_time; - double min_warmup_time; + const double min_time; + const double min_warmup_time; bool warmup_done; - int repeats; + const int repeats; const bool has_explicit_iteration_count; int num_repetitions_done = 0;