From 3762b0d6c9b4544f019cca062c09e8d42a323721 Mon Sep 17 00:00:00 2001 From: Matthias Maier Date: Wed, 31 May 2017 04:20:43 -0500 Subject: [PATCH] Tests: Make base/timer_03 test more robust Closes #4439 --- tests/base/timer_03.cc | 38 ++++++++++++++++++++++---------------- tests/base/timer_03.output | 1 - 2 files changed, 22 insertions(+), 17 deletions(-) diff --git a/tests/base/timer_03.cc b/tests/base/timer_03.cc index 31139a7f71..ba908bc6a2 100644 --- a/tests/base/timer_03.cc +++ b/tests/base/timer_03.cc @@ -79,30 +79,36 @@ int main () TimerOutput tO(std::cout, TimerOutput::summary, TimerOutput::cpu_times); + tO.enter_section("Section1"); - tO.enter_section("Section3"); - tO.enter_section("Section4"); - burn (50); - tO.exit_section("Section1"); - tO.exit_section("Section4"); tO.enter_section("Section2"); burn (50); tO.exit_section("Section2"); - tO.exit_section("Section3"); - tO.enter_section("Section4"); + tO.enter_section("Section2"); burn (50); - tO.exit_section("Section4"); + tO.exit_section("Section2"); + tO.exit_section("Section1"); - std::map cpu_times = tO.get_summary_data(TimerOutput::OutputData::total_cpu_time); - std::map calls = tO.get_summary_data(TimerOutput::OutputData::n_calls); + std::map cpu_times = + tO.get_summary_data(TimerOutput::OutputData::total_cpu_time); + std::map wall_times = + tO.get_summary_data(TimerOutput::OutputData::total_wall_time); + std::map calls = + tO.get_summary_data(TimerOutput::OutputData::n_calls); match(calls["Section1"], 1.0); - match(calls["Section2"], 1.0); - match(calls["Section3"], 1.0); - match(calls["Section4"], 2.0); + match(calls["Section2"], 2.0); + + if (cpu_times["Section1"] * cpu_times["Section2"] > 0.) + deallog << "OK" << std::endl; + else + deallog << "ERROR - total cpu time 0" << std::endl; + + if (wall_times["Section1"] * wall_times["Section2"] > 0.) + deallog << "OK" << std::endl; + else + deallog << "ERROR - total wall time 0" << std::endl; compare (cpu_times["Section1"],cpu_times["Section2"],1.); - compare (cpu_times["Section1"],cpu_times["Section3"],2.); - compare (cpu_times["Section3"],cpu_times["Section4"],1.); + compare (wall_times["Section1"],wall_times["Section2"],1.); } - diff --git a/tests/base/timer_03.output b/tests/base/timer_03.output index 5cf798a265..0aa61ff573 100644 --- a/tests/base/timer_03.output +++ b/tests/base/timer_03.output @@ -5,4 +5,3 @@ DEAL::OK DEAL::OK DEAL::OK DEAL::OK -DEAL::OK -- 2.39.5