Class c_clock_policy
Synopsis
#include "breeze/time/c_clock_timer.hpp"
class c_clock_policy
Description
A policy for our timer
template using the C function clock()
.
- Warning
- Note that on some (non-conforming) implementations
clock()
will actually measure wall-clock time. One such implementation is the Microsoft one:
https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/clock.
Methods
c_clock_policy overload | Deleted copy constructor. | |
c_clock_policy overload | Leaves this object in an undefined state | |
elapsed | Returns: The time, in milliseconds, elapsed from the last (re)start. | |
operator= | Deleted copy assignment operator. | |
resolution | Returns: An estimate of the timer resolution, in milliseconds | |
start | Starts or restarts measurement (see elapsed()). |
Source
Lines 37-93 in breeze/time/c_clock_timer.hpp.
class c_clock_policy
{
public:
//! Deleted copy constructor.
// -----------------------------------------------------------------------
c_clock_policy( c_clock_policy const & ) = delete ;
//! Deleted copy assignment operator.
// -----------------------------------------------------------------------
c_clock_policy & operator =( c_clock_policy const & ) = delete ;
//! The type used to represent a duration.
// -----------------------------------------------------------------------
typedef std::chrono::duration< double, std::milli >
duration_type ;
//! Leaves this object in an undefined state. The only action
//! that can be performed on a just constructed object is to
//! call start().
// -----------------------------------------------------------------------
c_clock_policy() ;
//! Starts or restarts measurement (see elapsed()).
//!
//! \par Exceptions
//! A \c std::runtime_error if \c std::clock() fails.
// -----------------------------------------------------------------------
void start() ;
//! \return
//! The time, in milliseconds, elapsed from the last
//! (re)start.
//!
//! \pre
//! The function start() has been called at least once.
//!
//! \par Exceptions
//! A \c std::runtime_error if it detects wrap-around (it
//! only detects \e some wrap-arounds), or if \c
//! std::clock() fails.
// -----------------------------------------------------------------------
duration_type elapsed() const ;
//! \return
//! An estimate of the timer resolution, in milliseconds.
//! May return slightly different values from call to call.
//!
//! \par Exceptions
//! A \c std::runtime_error if it detects wrap-around (it
//! only detects \e some wrap-arounds), or if \c
//! std::clock() fails.
// -----------------------------------------------------------------------
duration_type resolution() const ;
private:
std::clock_t m_start_tick ;
} ;