Timer.h
Go to the documentation of this file.
1 #ifndef _TIMER_H
2 #define _TIMER_H
3 
4 #include <ctime>
5 
6 struct TimerInfo
7 {
10 
13 
15  double duration_sec;
16 };
17 
18 inline void timer_start (TimerInfo *timer)
19 {
20 
21  struct timespec system_time_;
22  clock_gettime(CLOCK_REALTIME, &system_time_);
23 
24  timer->clock_start_value = static_cast<double>(system_time_.tv_sec) + static_cast<double>(system_time_.tv_nsec) * 1.e-9;
25 }
26 
27 inline double timer_stop (TimerInfo *timer)
28 {
29  struct timespec system_time_;
30  clock_gettime(CLOCK_REALTIME, &system_time_);
31 
32  timer->clock_end_value = static_cast<double>(system_time_.tv_sec) + static_cast<double>(system_time_.tv_nsec) * 1.e-9;
33 
34  timer->duration_sec = timer->clock_end_value - timer->clock_start_value;
35 
36  return timer->duration_sec;
37 }
38 
39 #endif
double clock_start_value
time stamp when timer_start() gets called
Definition: Timer.h:9
double timer_stop(TimerInfo *timer)
Definition: Timer.h:27
double clock_end_value
time stamp when the timer was stopped
Definition: Timer.h:12
double duration_sec
duration between clock_start_value and clock_end_value in seconds
Definition: Timer.h:15
void timer_start(TimerInfo *timer)
Definition: Timer.h:18
Definition: Timer.h:6


rdl_benchmark
Author(s):
autogenerated on Tue Apr 20 2021 02:25:39