Beam-lib  2.16.3
This is the Beam C++ class library.
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) 2012 All Right Reserved, Beam Ltd, http://www.beam.ltd.uk
5  *******************************************************************************
6  */
7 #ifndef BTIMER_H
8 #define BTIMER_H
9 
10 #include <BMutex.h>
11 
13 class BTimer {
14 public:
15  BTimer();
16  ~BTimer();
17 
18  void start();
19  void stop();
20  void clear();
21  double getElapsedTime();
22 
23  // Overall operations
24  void add(BTimer& timer);
25 
26  // Statistics
27  double average();
28  double peak();
29 private:
30  static double getTime();
31 
32  BMutex olock;
33  unsigned int onum;
34  double ostartTime;
35  double oendTime;
36  double oaverage;
37  double opeak;
38 };
39 #endif
~BTimer()
Definition: BTimer.cpp:13
void start()
Start timer.
Definition: BTimer.cpp:47
double getElapsedTime()
Returns the elapsed time from the last start.
Definition: BTimer.cpp:66
double peak()
Peak time.
Definition: BTimer.cpp:85
Stopwatch style timer.
Definition: BTimer.h:13
double average()
Average time is duration between start() and stop() / number of stops.
Definition: BTimer.cpp:76
Definition: BMutex.h:14
void stop()
Stop timer.
Definition: BTimer.cpp:54
void clear()
Clear timer.
Definition: BTimer.cpp:37
BTimer()
Definition: BTimer.cpp:9
void add(BTimer &timer)
Add two timers.
Definition: BTimer.cpp:24