Beamlib 3.1.1
This is the Beam C++ class library.
Loading...
Searching...
No Matches
BTimer.h
Go to the documentation of this file.
1/*******************************************************************************
2 * BTimer.h Quantel Quentin BTimers
3 * T.Barnaby, BEAM Ltd, 3/2/04
4 * Copyright (c) 2022 All Right Reserved, Beam Ltd, https://www.beam.ltd.uk
5 * For license see LICENSE.txt at the root of the beamlib source tree.
6 *******************************************************************************
7 */
8#ifndef BTIMER_H
9#define BTIMER_H
10
11#include <BMutex.h>
12
14class BTimer {
15public:
16 BTimer();
17 ~BTimer();
18
19 void start();
20 void stop();
21 void clear();
22 double getElapsedTime();
23
24 // Overall operations
25 void add(BTimer& timer);
26
27 // Statistics
28 double average();
29 double peak();
30private:
31 static double getTime();
32
33 BMutex olock;
34 unsigned int onum;
35 double ostartTime;
36 double oendTime;
37 double oaverage;
38 double opeak;
39};
40#endif
Mutex class. Note these are recursive Mutexes and so you need to make sure the number of unlocks equa...
Definition: BMutex.h:14
Stopwatch style timer.
Definition: BTimer.h:14
void start()
Start timer.
Definition: BTimer.cpp:49
~BTimer()
Definition: BTimer.cpp:15
void add(BTimer &timer)
Add two timers.
Definition: BTimer.cpp:26
double getElapsedTime()
Returns the elapsed time from the last start.
Definition: BTimer.cpp:68
double average()
Average time is duration between start() and stop() / number of stops.
Definition: BTimer.cpp:78
void stop()
Stop timer.
Definition: BTimer.cpp:56
void clear()
Clear timer.
Definition: BTimer.cpp:39
double peak()
Peak time.
Definition: BTimer.cpp:87
BTimer()
Definition: BTimer.cpp:11