]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Add test case
authorMartin Kronbichler <kronbichler@lnm.mw.tum.de>
Mon, 3 Feb 2020 16:45:26 +0000 (17:45 +0100)
committerMartin Kronbichler <kronbichler@lnm.mw.tum.de>
Mon, 3 Feb 2020 16:45:26 +0000 (17:45 +0100)
tests/base/timer_09.cc [new file with mode: 0644]
tests/base/timer_09.with_mpi=true.mpirun=2.output [new file with mode: 0644]

diff --git a/tests/base/timer_09.cc b/tests/base/timer_09.cc
new file mode 100644 (file)
index 0000000..a021657
--- /dev/null
@@ -0,0 +1,76 @@
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2018 by the deal.II authors
+//
+// This file is part of the deal.II library.
+//
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE.md at
+// the top level directory of deal.II.
+//
+// ---------------------------------------------------------------------
+
+
+// test TimerOutput::print_summary_of_wall_time_statistics()
+
+#include <deal.II/base/timer.h>
+
+#include <algorithm>
+#include <sstream>
+
+#include "../tests.h"
+
+// burn computer time
+double s = 0.;
+void
+burn(unsigned int n)
+{
+  for (unsigned int i = 0; i < n; ++i)
+    {
+      for (unsigned int j = 1; j < 100000; ++j)
+        {
+          s += 1. / j * i;
+        }
+    }
+}
+
+void
+test()
+{
+  std::stringstream ss;
+
+  TimerOutput t(ss, TimerOutput::never, TimerOutput::wall_times);
+
+  t.enter_subsection("hi");
+  burn(50);
+  t.leave_subsection("hi");
+
+  t.print_summary_of_wall_time_statistics(MPI_COMM_WORLD);
+
+  t.enter_subsection(
+    "this is a very long section name that previously did not work");
+  burn(50);
+  t.leave_subsection(
+    "this is a very long section name that previously did not work");
+
+  t.print_summary_of_wall_time_statistics(MPI_COMM_WORLD);
+
+  std::string s = ss.str();
+  std::replace_if(s.begin(), s.end(), ::isdigit, ' ');
+  std::replace_if(s.begin(), s.end(), [](char x) { return x == '.'; }, ' ');
+
+  deallog << s << std::endl << std::endl;
+}
+
+int
+main(int argc, char **argv)
+{
+  Utilities::MPI::MPI_InitFinalize mpi(argc, argv);
+
+  mpi_initlog();
+
+  test();
+}
diff --git a/tests/base/timer_09.with_mpi=true.mpirun=2.output b/tests/base/timer_09.with_mpi=true.mpirun=2.output
new file mode 100644 (file)
index 0000000..b6815a7
--- /dev/null
@@ -0,0 +1,24 @@
+
+DEAL::
+
++---------------------------------+------------+------+------------+------------+------+
+| Total wallclock time elapsed    |          s |      |          s |          s |      |
+|                                 |            |  min |            |            |  max |
+| Section             | no  calls |   min time | rank |   avg time |   max time | rank |
++---------------------+-----------+------------+------+------------+------------+------+
+| hi                  |           |          s |      |          s |          s |      |
++---------------------+-----------+------------+------+------------+------------+------+
+
+
+
++---------------------------------------------------------------------------+------------+------+------------+------------+------+
+| Total wallclock time elapsed                                              |          s |      |          s |          s |      |
+|                                                                           |            |  min |            |            |  max |
+| Section                                                       | no  calls |   min time | rank |   avg time |   max time | rank |
++---------------------------------------------------------------+-----------+------------+------+------------+------------+------+
+| hi                                                            |           |          s |      |          s |          s |      |
+| this is a very long section name that previously did not work |           |          s |      |          s |          s |      |
++---------------------------------------------------------------+-----------+------------+------+------------+------------+------+
+
+
+DEAL::

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.