// $Id$
// Version: $Name$
//
-// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 by the deal.II authors
+// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009 by the deal.II authors
//
// This file is subject to QPL and may not be distributed
// without copyright and license information. Please refer
* @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. Furthermore, a wall clock option would be nice.
+ * all children.
*
* @ingroup utilities
* @author G. Kanschat, W. Bangerth
*/
double operator() () const;
+ /**
+ * Access to the current wall time
+ * without disturbing time
+ * measurement. The elapsed time is
+ * returned in units of seconds.
+ */
+ double wall_time () const;
+
private:
/**
*/
double start_time_children;
+ /**
+ * Value of the wall time when start()
+ * was called the last time or when the
+ * object was created and no stop() was
+ * issued in between.
+ */
+ double start_wall_time;
+
/**
* Accumulated time for all previous
* start()/stop() cycles. The time for
double cumulative_time;
+ /**
+ * Accumulated waoo time for all
+ * previous start()/stop() cycles. The
+ * wall time for the present cycle is
+ * not included.
+ */
+ double cumulative_wall_time;
+
+
/**
* Store whether the timer is presently
* running.
// $Id$
// Version: $Name$
//
-// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2005, 2006 by the deal.II authors
+// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2005, 2006, 2009 by the deal.II authors
//
// This file is subject to QPL and may not be distributed
// without copyright and license information. Please refer
Timer::Timer()
:
- cumulative_time (0.)
+ cumulative_time (0.),
+ cumulative_wall_time (0.)
{
start();
}
void Timer::start ()
{
running = true;
+
+ struct timeval wall_timer;
+ gettimeofday(&wall_timer, NULL);
+ start_wall_time = wall_timer.tv_sec + 1.e-6 * wall_timer.tv_usec;
+
rusage usage;
getrusage (RUSAGE_SELF, &usage);
start_time = usage.ru_utime.tv_sec + 1.e-6 * usage.ru_utime.tv_usec;
const double dtime_children =
usage_children.ru_utime.tv_sec + 1.e-6 * usage_children.ru_utime.tv_usec;
cumulative_time += dtime_children - start_time_children;
+
+ struct timeval wall_timer;
+ gettimeofday(&wall_timer, NULL);
+ cumulative_wall_time += wall_timer.tv_sec + 1.e-6 * wall_timer.tv_usec
+ - start_wall_time;
}
return cumulative_time;
}
+double Timer::wall_time () const
+{
+ if (running)
+ {
+ struct timeval wall_timer;
+ gettimeofday(&wall_timer, NULL);
+ return wall_timer.tv_sec + 1.e-6 * wall_timer.tv_usec - start_wall_time +
+ cumulative_wall_time;
+ }
+ else
+ return cumulative_wall_time;
+}
+
+
+
void Timer::reset ()
{
cumulative_time = 0.;
+ cumulative_wall_time = 0.;
running = false;
}