Quantum++  v1.0.0-beta1
C++11 quantum computing library
qpp::Timer< T, CLOCK_T > Class Template Reference

Chronometer. More...

#include <classes/timer.h>

Inheritance diagram for qpp::Timer< T, CLOCK_T >:
Collaboration diagram for qpp::Timer< T, CLOCK_T >:

Public Member Functions

 Timer () noexcept
 Constructs an instance with the current time as the starting point. More...
 
void tic () noexcept
 Resets the chronometer. More...
 
const Timertoc () noexcept
 Stops the chronometer. More...
 
double tics () const noexcept
 Time passed in the duration specified by T. More...
 
template<typename U = T>
get_duration () const noexcept
 Duration specified by U. More...
 
 Timer (const Timer &)=default
 Default copy constructor. More...
 
 Timer (Timer &&)=default
 Default move constructor. More...
 
Timeroperator= (const Timer &)=default
 Default copy assignment operator. More...
 
Timeroperator= (Timer &&)=default
 Default move assignment operator. More...
 
virtual ~Timer ()=default
 Default virtual destructor. More...
 
- Public Member Functions inherited from qpp::IDisplay
 IDisplay ()=default
 Default constructor. More...
 
 IDisplay (const IDisplay &)=default
 Default copy constructor. More...
 
 IDisplay (IDisplay &&)=default
 Default move constructor. More...
 
IDisplayoperator= (const IDisplay &)=default
 Default copy assignment operator. More...
 
IDisplayoperator= (IDisplay &&)=default
 Default move assignment operator. More...
 
virtual ~IDisplay ()=default
 Default virtual destructor. More...
 

Protected Attributes

CLOCK_T::time_point start_
 
CLOCK_T::time_point end_
 

Private Member Functions

std::ostream & display (std::ostream &os) const override
 qpp::IDisplay::display() override More...
 

Detailed Description

template<typename T = std::chrono::duration<double>, typename CLOCK_T = std::chrono::steady_clock>
class qpp::Timer< T, CLOCK_T >

Chronometer.

Template Parameters
TTics duration, default is std::chrono::duration<double, 1>, i.e. seconds in double precision
CLOCK_TClock's type, default is std::chrono::steady_clock, not affected by wall clock changes during runtime

Constructor & Destructor Documentation

template<typename T = std::chrono::duration<double>, typename CLOCK_T = std::chrono::steady_clock>
qpp::Timer< T, CLOCK_T >::Timer ( )
inlinenoexcept

Constructs an instance with the current time as the starting point.

template<typename T = std::chrono::duration<double>, typename CLOCK_T = std::chrono::steady_clock>
qpp::Timer< T, CLOCK_T >::Timer ( const Timer< T, CLOCK_T > &  )
default

Default copy constructor.

template<typename T = std::chrono::duration<double>, typename CLOCK_T = std::chrono::steady_clock>
qpp::Timer< T, CLOCK_T >::Timer ( Timer< T, CLOCK_T > &&  )
default

Default move constructor.

template<typename T = std::chrono::duration<double>, typename CLOCK_T = std::chrono::steady_clock>
virtual qpp::Timer< T, CLOCK_T >::~Timer ( )
virtualdefault

Default virtual destructor.

Member Function Documentation

template<typename T = std::chrono::duration<double>, typename CLOCK_T = std::chrono::steady_clock>
std::ostream& qpp::Timer< T, CLOCK_T >::display ( std::ostream &  os) const
inlineoverrideprivatevirtual

qpp::IDisplay::display() override

Parameters
osOutput stream
Returns
Writes to the output stream the number of tics (specified by T) that passed between the instantiation/reset and invocation of qpp::Timer::toc().

Implements qpp::IDisplay.

template<typename T = std::chrono::duration<double>, typename CLOCK_T = std::chrono::steady_clock>
template<typename U = T>
U qpp::Timer< T, CLOCK_T >::get_duration ( ) const
inlinenoexcept

Duration specified by U.

Template Parameters
UDuration, default is T, which defaults to std::chrono::duration<double, 1>, i.e. seconds in double precision
Returns
Duration that passed between the instantiation/reset and invocation of qpp::Timer::toc()
template<typename T = std::chrono::duration<double>, typename CLOCK_T = std::chrono::steady_clock>
Timer& qpp::Timer< T, CLOCK_T >::operator= ( const Timer< T, CLOCK_T > &  )
default

Default copy assignment operator.

template<typename T = std::chrono::duration<double>, typename CLOCK_T = std::chrono::steady_clock>
Timer& qpp::Timer< T, CLOCK_T >::operator= ( Timer< T, CLOCK_T > &&  )
default

Default move assignment operator.

template<typename T = std::chrono::duration<double>, typename CLOCK_T = std::chrono::steady_clock>
void qpp::Timer< T, CLOCK_T >::tic ( )
inlinenoexcept

Resets the chronometer.

Resets the starting/ending point to the current time

template<typename T = std::chrono::duration<double>, typename CLOCK_T = std::chrono::steady_clock>
double qpp::Timer< T, CLOCK_T >::tics ( ) const
inlinenoexcept

Time passed in the duration specified by T.

Returns
Number of tics (specified by T) that passed between the instantiation/reset and invocation of qpp::Timer::toc()
template<typename T = std::chrono::duration<double>, typename CLOCK_T = std::chrono::steady_clock>
const Timer& qpp::Timer< T, CLOCK_T >::toc ( )
inlinenoexcept

Stops the chronometer.

Set the current time as the ending point

Returns
Current instance

Member Data Documentation

template<typename T = std::chrono::duration<double>, typename CLOCK_T = std::chrono::steady_clock>
CLOCK_T::time_point qpp::Timer< T, CLOCK_T >::end_
protected
template<typename T = std::chrono::duration<double>, typename CLOCK_T = std::chrono::steady_clock>
CLOCK_T::time_point qpp::Timer< T, CLOCK_T >::start_
protected

The documentation for this class was generated from the following file: