From a80c9ea0a486f514d38930abe7f937e1ed294984 Mon Sep 17 00:00:00 2001 From: Jacob Domagala Date: Fri, 26 Apr 2024 21:07:51 +0200 Subject: [PATCH] #2275: Add option to disable global timers on performance tests. This is useful for tests that use custom timers --- tests/perf/common/test_harness.cc | 8 ++++++++ tests/perf/common/test_harness.h | 7 +++++++ tests/perf/common/test_harness_macros.h | 9 ++++++--- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/tests/perf/common/test_harness.cc b/tests/perf/common/test_harness.cc index 669ff9d028..2d5044f3a1 100644 --- a/tests/perf/common/test_harness.cc +++ b/tests/perf/common/test_harness.cc @@ -454,4 +454,12 @@ void PerfTestHarness::GetMemoryUsage() { print_memory_use_ = true; } +void PerfTestHarness::DisableGlobalTimer() { + print_total_time_ = false; +} + +bool PerfTestHarness::ShouldOutputGlobalTimer() const { + return print_total_time_; +} + }}}} // namespace vt::tests::perf::common diff --git a/tests/perf/common/test_harness.h b/tests/perf/common/test_harness.h index 113ac3175b..a2e160c5dc 100644 --- a/tests/perf/common/test_harness.h +++ b/tests/perf/common/test_harness.h @@ -167,6 +167,12 @@ struct PerfTestHarness : TestHarnessBase { */ void GetMemoryUsage(); + void + DisableGlobalTimer(); + + bool + ShouldOutputGlobalTimer() const; + private: std::string OutputMemoryUse() const; std::string OutputTimeResults(); @@ -175,6 +181,7 @@ struct PerfTestHarness : TestHarnessBase { bool gen_file_ = false; bool verbose_ = false; bool print_memory_use_ = false; + bool print_total_time_ = true; uint32_t num_runs_ = 20; uint32_t current_run_ = 0; std::vector custom_args_ = {}; diff --git a/tests/perf/common/test_harness_macros.h b/tests/perf/common/test_harness_macros.h index 82abd1c4e5..bb668cfe26 100644 --- a/tests/perf/common/test_harness_macros.h +++ b/tests/perf/common/test_harness_macros.h @@ -121,8 +121,8 @@ struct PerfTestRegistry{ if (rank == 0) { \ fmt::print( \ "{}{}RUNNING TEST:{} {} (Number of runs = {}) ...\n", \ - test_num > 0 ? "\n\n\n\n" : "", vt::debug::bold(), vt::debug::reset(), \ - vt::debug::reg(test->GetName()), \ + test_num > 0 ? "\n\n\n\n" : "", vt::debug::bold(), \ + vt::debug::reset(), vt::debug::reg(test->GetName()), \ vt::debug::reg(fmt::format("{}", num_runs))); \ } \ for (uint32_t run_num = 1; run_num <= num_runs; ++run_num) { \ @@ -131,7 +131,10 @@ struct PerfTestRegistry{ timer.Start(); \ test->TestFunc(); \ PerfTestHarness::SpinScheduler(); \ - test->AddResult({test->GetName(), timer.Stop()}); \ + \ + if (test->ShouldOutputGlobalTimer()) { \ + test->AddResult({test->GetName(), timer.Stop()}); \ + } \ \ if (run_num == num_runs) { \ test->SyncResults(); \