MeVisLab Toolbox Reference
mlTimer.h
Go to the documentation of this file.
1 /*************************************************************************************
2 **
3 ** Copyright 2010, MeVis Medical Solutions AG
4 **
5 ** The user may use this file in accordance with the license agreement provided with
6 ** the Software or, alternatively, in accordance with the terms contained in a
7 ** written agreement between the user and MeVis Medical Solutions AG.
8 **
9 ** For further information use the contact form at https://www.mevislab.de/contact
10 **
11 **************************************************************************************/
12 
13 // A timer implementation that is thread aware.
14 
15 #ifndef ML_TIMER_H
16 #define ML_TIMER_H
17 
19 
20 
21 class MLTimeProfile;
22 
24 {
25 public:
26  MLTimer() noexcept = default;
27  ~MLTimer() noexcept;
28 
29  MLTimer(const MLTimer&) = delete;
30  MLTimer& operator=(const MLTimer&) = delete;
31 
32  MLTimer(MLTimer&&) noexcept = default;
33  MLTimer& operator=(MLTimer&&) noexcept = default;
34 
35  void start();
36  void stop();
37 
39  void start(MLTimer& otherToPause);
40 
42  void stop(MLTimer& otherToResume);
43 
47  double elapsed() const { return _elapsed; }
48 
51  double consumed() const { return _elapsed - _pausedElapsed; }
52  unsigned int startCount() const { return _startCount; }
53 
54 private:
55  double _startTime {0};
56  double _pausedStartTime {0};
57  double _pausedElapsed {0};
58  double _elapsed {0};
59  bool _isActive {false};
60  bool _isPaused {false};
61  unsigned int _startCount {0};
62 
63  friend class MLTimeProfile;
64  friend class MLCallGraphNode;
65 };
66 
67 
68 #endif
MLTimer() noexcept=default
double consumed() const
Returns the elapsed time minus the time between pause() and resume() calls in seconds.
Definition: mlTimer.h:51
unsigned int startCount() const
Definition: mlTimer.h:52
#define MLPROFILINGMANAGER_EXPORT