]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Tests: Make base/timer_03 test more robust
authorMatthias Maier <tamiko@43-1.org>
Wed, 31 May 2017 09:20:43 +0000 (04:20 -0500)
committerMatthias Maier <tamiko@43-1.org>
Wed, 31 May 2017 10:30:51 +0000 (05:30 -0500)
Closes #4439

tests/base/timer_03.cc
tests/base/timer_03.output

index 31139a7f719be20a88b2d23866468b6268d5896f..ba908bc6a2d6dfd6bfca2423b3e1b4f43fd58627 100644 (file)
@@ -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<std::string, double> cpu_times = tO.get_summary_data(TimerOutput::OutputData::total_cpu_time);
-  std::map<std::string, double> calls = tO.get_summary_data(TimerOutput::OutputData::n_calls);
+  std::map<std::string, double> cpu_times =
+      tO.get_summary_data(TimerOutput::OutputData::total_cpu_time);
+  std::map<std::string, double> wall_times =
+      tO.get_summary_data(TimerOutput::OutputData::total_wall_time);
+  std::map<std::string, double> 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.);
 }
-
index 5cf798a265d99d683e291da992a70c69f17a6167..0aa61ff573b91e6ae8d4a06474a0678fa9ec448f 100644 (file)
@@ -5,4 +5,3 @@ DEAL::OK
 DEAL::OK
 DEAL::OK
 DEAL::OK
-DEAL::OK

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.