Base module

Stopwatch

A simple facility to measure time intervals with microsecond resolution.

Stopwatch

#include <icy/datetime.h>

A simple facility to measure time intervals with microsecond resolution.

The Stopwatch uses the current system time, so if the system time changes the measured time will be incorrect.

Public Methods

ReturnNameDescription
Stopwatch
voidstartStarts (or restarts) the stopwatch.
voidstopStops or pauses the stopwatch.
voidresetResets the stopwatch.
voidrestartResets and starts the stopwatch.
Timestamp::TimeDiffelapsed constReturns the elapsed time in microseconds since the stopwatch started.
intelapsedSeconds constReturns the number of seconds elapsed since the stopwatch started.
intelapsedMilliseconds constReturns the number of milliseconds elapsed since the stopwatch started.

Stopwatch

Stopwatch()

start

void start()

Starts (or restarts) the stopwatch.


stop

void stop()

Stops or pauses the stopwatch.


reset

void reset()

Resets the stopwatch.


restart

void restart()

Resets and starts the stopwatch.


elapsed

const

Timestamp::TimeDiff elapsed() const

Returns the elapsed time in microseconds since the stopwatch started.


elapsedSeconds

const

int elapsedSeconds() const

Returns the number of seconds elapsed since the stopwatch started.


elapsedMilliseconds

const

int elapsedMilliseconds() const

Returns the number of milliseconds elapsed since the stopwatch started.

Public Static Methods

ReturnNameDescription
Timestamp::TimeValresolution staticReturns the resolution of the stopwatch.

resolution

static

static Timestamp::TimeVal resolution()

Returns the resolution of the stopwatch.

Private Attributes

ReturnNameDescription
Timestamp_start
Timestamp::TimeDiff_elapsed
bool_running

_start

Timestamp _start

_elapsed

Timestamp::TimeDiff _elapsed

_running

bool _running

Private Methods

ReturnNameDescription
StopwatchDeleted constructor.

Stopwatch

Stopwatch(const Stopwatch &) = delete

Deleted constructor.