<h3>Specific improvements</h3>
<ol>
+ <li> New: Timer now has get_lap_time() which returns the time
+ lapsed between the last start()/stop() cycle.
+ <br>
+ (Fahad Alrashed, 2014/11/09)
+ </li>
+
<li> New: TableHandler objects can be cleared - i.e. reset to a
zero-sized state.
<br>
*/
double wall_time () const;
+ /**
+ * Returns the last lap time; the
+ * time taken between the last start()/stop()
+ * call.
+ */
+ double get_lap_time () const;
+
private:
/**
*/
double cumulative_wall_time;
+ /**
+ * Stores the last lap time; the time
+ * between the last start()/stop() cycle.
+ */
+ double last_lap_time;
+
/**
* Store whether the timer is presently
* running.
struct timeval wall_timer;
gettimeofday(&wall_timer, NULL);
- double time = wall_timer.tv_sec + 1.e-6 * wall_timer.tv_usec
- - start_wall_time;
+ last_lap_time = wall_timer.tv_sec + 1.e-6 * wall_timer.tv_usec
+ - start_wall_time;
#elif defined(DEAL_II_MSVC)
- double time = windows::wall_clock() - start_wall_time;
+ last_lap_time = windows::wall_clock() - start_wall_time;
cumulative_time += windows::cpu_clock() - start_time;
#else
# error Unsupported platform. Porting not finished.
if (sync_wall_time && Utilities::System::job_supports_mpi())
{
this->mpi_data
- = Utilities::MPI::min_max_avg (time, mpi_communicator);
-
- cumulative_wall_time += this->mpi_data.max;
+ = Utilities::MPI::min_max_avg (last_lap_time, mpi_communicator);
+ last_lap_time = this->mpi_data.max;
+ cumulative_wall_time += last_lap_time;
}
else
#endif
- cumulative_wall_time += time;
+ cumulative_wall_time += last_lap_time;
}
return cumulative_time;
}
+double Timer::get_lap_time() const
+{
+ // time already has the difference
+ // between the last start()/stop()
+ // cycle.
+#ifdef DEAL_II_WITH_MPI
+ if (Utilities::System::job_supports_mpi())
+ return Utilities::MPI::max (last_lap_time, mpi_communicator);
+ else
+#endif
+ return last_lap_time;
+
+}
+
+
+
double Timer::operator() () const
{
if (running)
void Timer::reset ()
{
+ last_lap_time = 0.;
cumulative_time = 0.;
cumulative_wall_time = 0.;
running = false;