SolidUtils
Classes | Public Member Functions | Static Public Member Functions | List of all members
sl::Timer Class Reference

This class is used to perform wall timings of varius tasks. It provides means to meanually start and stop a timer: More...

#include <Timer.hpp>

Classes

class  Scope
 This class provides a means of timing a scoped region. It begins timing when it is created, and adds its duration to the parent timer when it is destroyed. More...
 

Public Member Functions

 Timer ()
 Creat a new timer.
 
Scope scope ()
 Start a new timed scope. The duration from when the Scope object is created. More...
 
void start ()
 Start or continue the timer.
 
void stop ()
 Stop the timer.
 
double poll () const
 Get the elapsed number of seconds on the timer. More...
 
void add (double duration)
 Add some amount of time to the timer. More...
 

Static Public Member Functions

static double now ()
 Get a double representing the current time in seconds. This is an arbitrary value by itself, but the relation between return values of two calls is the duration in seconds elapsed. More...
 

Detailed Description

This class is used to perform wall timings of varius tasks. It provides means to meanually start and stop a timer:

t.start();
// perform task 1
t.stop();
t.start();
// perform task 2
t.stop();
double duration = t.poll();

It also provides a means to time a scoped environment:

{
Timer::Scope scope = t.scope();
// perform task 1
}
{
Timer::Scope scope = t.scope();
// perform task 2
}
double duration = t.poll();

Member Function Documentation

◆ add()

void sl::Timer::add ( double  duration)
inline

Add some amount of time to the timer.

Parameters
durationThe time to add.

◆ now()

static double sl::Timer::now ( )
inlinestatic

Get a double representing the current time in seconds. This is an arbitrary value by itself, but the relation between return values of two calls is the duration in seconds elapsed.

Returns
The current time in seconds.

◆ poll()

double sl::Timer::poll ( ) const
inline

Get the elapsed number of seconds on the timer.

Returns
The amount of elapsed time.

◆ scope()

Scope sl::Timer::scope ( )
inline

Start a new timed scope. The duration from when the Scope object is created.

Returns

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