Skip to content

Commit

Permalink
#2275: Add option to disable global timers on performance tests. This…
Browse files Browse the repository at this point in the history
… is useful for tests that use custom timers
  • Loading branch information
JacobDomagala authored and cwschilly committed Sep 20, 2024
1 parent dde56d7 commit a80c9ea
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
8 changes: 8 additions & 0 deletions tests/perf/common/test_harness.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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
7 changes: 7 additions & 0 deletions tests/perf/common/test_harness.h
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,12 @@ struct PerfTestHarness : TestHarnessBase {
*/
void GetMemoryUsage();

void
DisableGlobalTimer();

bool
ShouldOutputGlobalTimer() const;

private:
std::string OutputMemoryUse() const;
std::string OutputTimeResults();
Expand All @@ -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<char*> custom_args_ = {};
Expand Down
9 changes: 6 additions & 3 deletions tests/perf/common/test_harness_macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -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) { \
Expand All @@ -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(); \
Expand Down

0 comments on commit a80c9ea

Please sign in to comment.