From: Martin Kronbichler Date: Mon, 3 Feb 2020 16:45:26 +0000 (+0100) Subject: Add test case X-Git-Tag: v9.2.0-rc1~556^2~2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4f1055559219537caec0ec021d8276c5ec7e835d;p=dealii.git Add test case --- diff --git a/tests/base/timer_09.cc b/tests/base/timer_09.cc new file mode 100644 index 0000000000..a021657983 --- /dev/null +++ b/tests/base/timer_09.cc @@ -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 + +#include +#include + +#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 index 0000000000..b6815a7c8e --- /dev/null +++ b/tests/base/timer_09.with_mpi=true.mpirun=2.output @@ -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::