UltraGrid
UltraGrid Low-Latency High-Resolution Transmission System
Loading...
Searching...
No Matches
timer-util.h
Go to the documentation of this file.
1/*
2 * =====================================================================================
3 *
4 * Filename: timer.h
5 *
6 * Description: Timer utils.
7 *
8 * Author: Milan Kabat, kabat@ics.muni.cz
9 *
10 * =====================================================================================
11 */
12
13#ifndef TIMER_INC
14#define TIMER_INC
15
16#include <chrono>
17
18#if defined __GNUC__ && __GNUC__ == 4 && __GNUC_MINOR__ == 6 // compat, GCC 4.6 didn't have steady_clock
19#define steady_clock system_clock
20#endif
21
26{
27 private:
28 std::chrono::time_point<std::chrono::steady_clock> start_time;
29 std::chrono::time_point<std::chrono::steady_clock> end_time;
30
31 public:
32 inline void start() {
33 start_time = std::chrono::steady_clock::now();
34 }
35
36 inline void end() {
37 end_time = std::chrono::steady_clock::now();
38 }
39
45 inline double
46 elapsed_time () const
47 {
48 return std::chrono::duration_cast<std::chrono::duration<double>>(end_time - start_time).count();
49 }
50
51 inline double
53 {
54 return std::chrono::duration_cast<std::chrono::duration<double, std::milli>>(end_time - start_time).count();
55 }
56
57 inline long
59 {
60 return std::chrono::duration_cast<std::chrono::duration<long, std::micro>>(end_time - start_time).count();
61 }
62}; /* ----- end of class Timer_util ----- */
63
64#endif /* ----- #ifndef TIMER_INC ----- */
65
This class implements timer utils.
Definition timer-util.h:26
void end()
Definition timer-util.h:36
double elapsed_time() const
Definition timer-util.h:46
double elapsed_time_ms() const
Definition timer-util.h:52
void start()
Definition timer-util.h:32
std::chrono::time_point< std::chrono::steady_clock > end_time
Definition timer-util.h:29
std::chrono::time_point< std::chrono::steady_clock > start_time
Definition timer-util.h:28
long elapsed_time_us() const
Definition timer-util.h:58
int count
Definition hd-rum.c:44