3es  0.7
3estimer.h
1 
2 #ifndef __INSEXTTIMER_
3 #define __INSEXTTIMER_
4 
5 #include "3es-core.h"
6 
7 #include <string>
8 
9 namespace tes
10 {
12  struct _3es_coreAPI Timing
13  {
15  long long s;
17  unsigned short ms;
19  unsigned short us;
21  unsigned short ns;
22 
24  inline Timing()
25  {
26  s = 0;
27  ms = us = ns = 0u;
28  }
29  };
30 
43  class _3es_coreAPI Timer
44  {
45  public:
47  Timer();
48 
50  void start();
51 
55  long long restart();
56 
58  void mark();
59 
64  bool hasElapsedMs(long long milliseconds);
65 
69  long long elapsedNowMS();
70 
74  long long elapsedNowUS();
75 
81  void elapsed(unsigned int& seconds, unsigned int& milliseconds, unsigned int& microseconds) const;
82 
86  void elapsed(Timing &timing) const;
87 
91  void elapsedNow(Timing &timing);
92 
96  static void split(long long timeNs, Timing &timing);
97 
103  static void split(long long timeUs, unsigned int& seconds, unsigned int& milliseconds, unsigned int& microseconds);
104 
110  double elapsedS() const;
111 
117  long long elapsedMS() const;
118 
125  long long elapsedUS() const;
126 
127  private:
129  char data[16];
130  };
131 
158  char _3es_coreAPI *timeValueString(char *buffer, size_t bufferLen, Timer &t);
159 
167  std::string _3es_coreAPI timeValueString(Timer& t);
168 
169 
198  char _3es_coreAPI *timeValueString(char *buffer, size_t bufferLen,
199  unsigned int s,
200  unsigned int ms = 0u,
201  unsigned int us = 0u);
202 
210  std::string _3es_coreAPI timeValueString(unsigned int s,
211  unsigned int ms = 0,
212  unsigned int us = 0u);
213 
215  const char _3es_coreAPI *timeValueString(char *buffer, size_t bufferLen, double seconds);
216 
218  std::string _3es_coreAPI timeValueString(double seconds);
219 
221  const char _3es_coreAPI *timeValueString(char *buffer, size_t bufferLen, long double seconds);
222 
224  std::string _3es_coreAPI timeValueString(long double seconds);
225 }
226 
227 #endif // __TIMER_
228 
Definition: 3esbounds.h:13
char _3es_coreAPI * timeValueString(char *buffer, size_t bufferLen, Timer &t)
Converts a Timer to a time string indicating the elapsed time.
long long s
Number of seconds elapsed.
Definition: 3estimer.h:15
unsigned short ms
Number of milliseconds [0, 1000).
Definition: 3estimer.h:17
Timing()
Initialise to zero.
Definition: 3estimer.h:24
unsigned short ns
Number of nanoseconds [0, 1000).
Definition: 3estimer.h:21
unsigned short us
Number of microseconds [0, 1000).
Definition: 3estimer.h:19
A timing information structure.
Definition: 3estimer.h:12
A high precision timer implementation.
Definition: 3estimer.h:43