1 // Copyright (C) 2006 Douglas Gregor <doug.gregor -at- gmail.com>
3 // Use, modification and distribution is subject to the Boost Software
4 // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
5 // http://www.boost.org/LICENSE_1_0.txt)
9 * This header provides the @c timer class, which provides access to
12 #ifndef BOOST_MPI_TIMER_HPP
13 #define BOOST_MPI_TIMER_HPP
15 #include <boost/mpi/config.hpp>
16 #include <boost/limits.hpp>
18 namespace boost
{ namespace mpi
{
20 /** @brief A simple timer that provides access to the MPI timing
23 * The @c timer class is a simple wrapper around the MPI timing
24 * facilities that mimics the interface of the Boost Timer library.
26 class BOOST_MPI_DECL timer
{
28 /** Initializes the timer
30 * @post @c elapsed() == 0
34 /** Restart the timer.
36 * @post @c elapsed() == 0
40 /** Return the amount of time that has elapsed since the last
41 * construction or reset, in seconds.
43 double elapsed() const;
45 /** Return an estimate of the maximum possible value of
46 * elapsed(). Note that this routine may return too high a value on
49 double elapsed_max() const;
51 /** Returns the minimum non-zero value that @c elapsed() may
52 * return. This is the resolution of the timer.
54 double elapsed_min() const;
56 /** Determines whether the elapsed time values are global times or
57 local processor times. */
58 static bool time_is_global();
69 inline void timer::restart()
71 start_time
= MPI_Wtime();
74 inline double timer::elapsed() const
76 return MPI_Wtime() - start_time
;
79 inline double timer::elapsed_max() const
81 return (std::numeric_limits
<double>::max
)();
84 inline double timer::elapsed_min() const
89 } } // end namespace boost::mpi
91 #endif // BOOST_MPI_TIMER_HPP