openATV enigma2
openATV is an open source SetTopBox Graphical user interface.
benchmark.h
Go to the documentation of this file.
1 #include <time.h>
2 
3 class Stopwatch
4 {
5 public:
6  struct timespec m_start;
7  struct timespec m_stop;
8 
10  {
11  clock_gettime(CLOCK_MONOTONIC, &m_start);
12  }
13 
14  void start()
15  {
16  clock_gettime(CLOCK_MONOTONIC, &m_start);
17  }
18 
19  void stop()
20  {
21  clock_gettime(CLOCK_MONOTONIC, &m_stop);
22  }
23 
24  unsigned int elapsed_us()
25  {
26  return
27  ((m_stop.tv_sec - m_start.tv_sec) * 1000000) +
28  (m_stop.tv_nsec - m_start.tv_nsec) / 1000;
29  }
30 };
Definition: benchmark.h:4
struct timespec m_start
Definition: benchmark.h:6
struct timespec m_stop
Definition: benchmark.h:7
Stopwatch()
Definition: benchmark.h:9
void start()
Definition: benchmark.h:14
unsigned int elapsed_us()
Definition: benchmark.h:24
void stop()
Definition: benchmark.h:19