From: David Wells Date: Mon, 4 Sep 2017 23:29:38 +0000 (-0400) Subject: Update the explanations of Timer in the tutorials. X-Git-Tag: v9.0.0-rc1~1109^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F5025%2Fhead;p=dealii.git Update the explanations of Timer in the tutorials. --- diff --git a/examples/step-28/step-28.cc b/examples/step-28/step-28.cc index 100d7d5251..a91988d8ae 100644 --- a/examples/step-28/step-28.cc +++ b/examples/step-28/step-28.cc @@ -21,7 +21,12 @@ // @sect3{Include files} // We start with a bunch of include files that have already been explained in -// previous tutorial programs: +// previous tutorial programs. One new one is timer.h: This is +// the first example program that uses the Timer class. The Timer keeps track +// of both the elapsed wall clock time (that is, the amount of time that a +// clock mounted on the wall would measure) and CPU clock time (the amount of +// time that the current process uses on the CPUs). We will use a Timer below +// to measure how much CPU time each grid refinement cycle takes. #include #include #include @@ -1640,11 +1645,15 @@ namespace Step28 double k_eff_old = k_eff; - Timer timer; - timer.start (); - for (unsigned int cycle=0; cycleoutput_results (cycle); + // Print out information about the simulation as well as the elapsed + // CPU time. We can call Timer::cpu_time() without first calling + // Timer::stop() to get the elapsed CPU time at the point of calling + // the function. std::cout << std::endl; std::cout << " Cycle=" << cycle << ", n_dofs=" << energy_groups[0]->n_dofs() + energy_groups[1]->n_dofs() diff --git a/examples/step-29/step-29.cc b/examples/step-29/step-29.cc index 42a64566ec..b3a210ee58 100644 --- a/examples/step-29/step-29.cc +++ b/examples/step-29/step-29.cc @@ -433,7 +433,6 @@ namespace Step29 // compute execution time when this function is done: deallog << "Generating grid... "; Timer timer; - timer.start (); // Then we query the values for the focal distance of the transducer lens // and the number of mesh refinement steps from our ParameterHandler @@ -525,7 +524,6 @@ namespace Step29 { deallog << "Setting up system... "; Timer timer; - timer.start(); dof_handler.distribute_dofs (fe); @@ -558,7 +556,6 @@ namespace Step29 { deallog << "Assembling system matrix... "; Timer timer; - timer.start (); // First we query wavespeed and frequency from the ParameterHandler object // and store them in local variables, as they will be used frequently @@ -805,7 +802,6 @@ namespace Step29 { deallog << "Solving linear system... "; Timer timer; - timer.start (); // The code to solve the linear system is short: First, we allocate an // object of the right type. The following initialize call @@ -843,7 +839,6 @@ namespace Step29 { deallog << "Generating output... "; Timer timer; - timer.start (); // Define objects of our ComputeIntensity class and a DataOut // object: diff --git a/examples/step-37/step-37.cc b/examples/step-37/step-37.cc index 99267758d8..9f3f6f42d6 100644 --- a/examples/step-37/step-37.cc +++ b/examples/step-37/step-37.cc @@ -804,7 +804,6 @@ namespace Step37 void LaplaceProblem::setup_system () { Timer time; - time.start (); setup_time = 0; system_matrix.clear(); diff --git a/include/deal.II/base/timer.h b/include/deal.II/base/timer.h index 7696d284b3..8aa7bdbec8 100644 --- a/include/deal.II/base/timer.h +++ b/include/deal.II/base/timer.h @@ -84,8 +84,7 @@ struct CPUClock * as well as the total time elapsed over all laps. Here is an example: * * @code - * Timer timer; - * timer.start(); + * Timer timer; // creating a timer also starts it * * // do some complicated computations here * // ... @@ -102,7 +101,10 @@ struct CPUClock * Alternatively, you can also restart the timer instead of resetting it. The * times between successive calls to start() and stop() (i.e., the laps) will * then be accumulated. The usage of this class is also explained in the - * step-28, step-29 and step-30 tutorial programs. + * step-28 tutorial program. + * + * @note The TimerOutput (combined with TimerOutput::Scope) class provide a + * convenient way to time multiple named sections and summarize the output. * * @note Implementation of this class is system dependent. In particular, CPU * times are accumulated from summing across all threads and will usually @@ -540,8 +542,8 @@ private: * TimerOutput::wall_times); * @endcode * Here, pcout is an object of type ConditionalOStream that makes - * sure that we only generate output on a single processor. See the step-32 - * and step-40 tutorial programs for this kind of usage of this class. + * sure that we only generate output on a single processor. See the step-32, + * step-40, and step-42 tutorial programs for this kind of usage of this class. * * @ingroup utilities * @author M. Kronbichler, 2009.