DGtal  1.5.beta
DGtal::Clock Class Reference

#include <DGtal/base/Clock.h>

Public Member Functions

void startClock ()
 
double stopClock () const
 
double restartClock ()
 
 Clock ()
 
 ~Clock ()
 
void selfDisplay (std::ostream &out) const
 
bool isValid () const
 

Private Attributes

struct timespec myTimerStart
 internal timer object; More...
 

Detailed Description

Description of class 'Clock'

Aim: To provide functions to start and stop a timer. Is useful to get performance of algorithms.

The following code snippet demonstrates how to use Clock

#include <DGtal/base/Clock.h>
Clock c;
long duration;
c.startClock();
...
//do something
...
duration = c.stopClock();
std::cout<< "Duration in ms. : "<< duration <<endl;
See also
testClock.cpp

Definition at line 95 of file Clock.h.

Constructor & Destructor Documentation

◆ Clock()

DGtal::Clock::Clock ( )

Constructor.

◆ ~Clock()

DGtal::Clock::~Clock ( )

Destructor.

Member Function Documentation

◆ isValid()

bool DGtal::Clock::isValid ( ) const

Checks the validity/consistency of the object.

Returns
'true' if the object is valid, 'false' otherwise.

◆ restartClock()

double DGtal::Clock::restartClock ( )

Restart the clock.

Returns
the time (in ms) since the last 'startClock()' or 'restartClock()'.

Referenced by test_RestartClock().

◆ selfDisplay()

void DGtal::Clock::selfDisplay ( std::ostream &  out) const

Writes/Displays the object on an output stream.

Parameters
outthe output stream where the object is written.

◆ startClock()

void DGtal::Clock::startClock ( )

Starts a clock.

Referenced by SCENARIO(), test_loopTick(), test_MultipleLoop(), and test_RestartClock().

◆ stopClock()

double DGtal::Clock::stopClock ( ) const

Stops the clock.

Returns
the time (in ms) since the last 'startClock()' or 'restartClock()'.

Referenced by test_MultipleLoop(), and test_RestartClock().

Field Documentation

◆ myTimerStart

struct timespec DGtal::Clock::myTimerStart
private

internal timer object;

Definition at line 141 of file Clock.h.


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