From: kronbichler Date: Mon, 25 Oct 2010 10:30:22 +0000 (+0000) Subject: Improve documentation of timer class: we actually do sum up times of children.. Inclu... X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=65702be25d686ecae305a0dd23a61968de632a12;p=dealii-svn.git Improve documentation of timer class: we actually do sum up times of children.. Include restart function as we say in the class documentation. git-svn-id: https://svn.dealii.org/trunk@22472 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/base/include/base/timer.h b/deal.II/base/include/base/timer.h index 603ca9bc97..ab4783f184 100644 --- a/deal.II/base/include/base/timer.h +++ b/deal.II/base/include/base/timer.h @@ -29,11 +29,12 @@ DEAL_II_NAMESPACE_OPEN /** - * This is a very simple class which provides information about both the - * CPU time and the wallclock time elapsed since the timer was started - * last time. Information is retrieved from the system on the basis of - * clock cycles since last time the computer was booted for the CPU - * time. + * This is a very simple class which provides information about both the CPU + * time and the wallclock time elapsed since the timer was started last + * time. Information is retrieved from the system on the basis of clock cycles + * since last time the computer was booted for the CPU time. The wall time is + * based on the system clock accessed by @p gettimeofday, with a typical + * accuracy of 0.01 ms on linux systems. * * *

Usage

@@ -41,7 +42,7 @@ DEAL_II_NAMESPACE_OPEN * Use of this class is as you might expect by looking at the member * functions: * @code - * Time timer; + * Timer timer; * timer.start (); * * // do some complicated computations here @@ -57,19 +58,17 @@ DEAL_II_NAMESPACE_OPEN * @endcode * * Alternatively, you can also restart the timer instead of resetting - * it. The times between successive calls to start()/ stop() will then be + * it. The times between successive calls to start() / stop() will then be * accumulated. The usage of this class is also explained in the * step-12 and step-29 tutorial programs. * - * @note Implementation of this class is system - * dependent. Unfortunately, it does not work with multithreading - * right now. In this case, we would like to sum up the time needed by - * all children. + * @note Implementation of this class is system dependent. In case + * multithreaded routines (matrix-vector products, error estimators, etc.) are + * used, the CPU time is accumulated from all the children. * * @ingroup utilities - * @author G. Kanschat, W. Bangerth + * @author G. Kanschat, W. Bangerth, M. Kronbichler */ -//TODO:[?] make class work with multithreading as well. better docs. class Timer { public: @@ -143,6 +142,14 @@ class Timer */ void reset (); + /** + * Resets the elapsed time to zero and + * starts the timer. This corresponds to + * calling @p reset() and @p start() on + * the Timer object. + */ + void restart(); + /** * Access to the current CPU time * without disturbing time @@ -234,6 +241,15 @@ class Timer */ bool sync_wall_time; + /** + * A structure for parallel wall time + * measurement that includes the minimum + * time recorded among all processes, the + * maximum time as well as the average + * time defined as the sum of all + * individual times divided by the number + * of MPI processes in the MPI_Comm. + */ Utilities::System::MinMaxAvg mpi_data; #endif }; @@ -512,6 +528,15 @@ class TimerOutput /* ---------------- inline functions ----------------- */ +inline +void Timer::restart () +{ + reset(); + start(); +} + + + #ifdef DEAL_II_COMPILER_SUPPORTS_MPI inline