returns the duration in ns
| 74 | |
| 75 | // returns the duration in ns |
| 76 | static inline long long stop_timer(timer_data * timer) { |
| 77 | timespec ts; |
| 78 | clock_gettime(CLOCK_MONOTONIC, &ts); |
| 79 | long long timer_end = (long long) ts.tv_sec * 1000000000LL + ts.tv_nsec; |
| 80 | |
| 81 | long long duration = (timer_end - timer->start); |
| 82 | timer->total += duration; |
| 83 | timer->count += 1; |
| 84 | |
| 85 | return duration; |
| 86 | } |