|
7 | 7 | // Timers are implemented using the std::chrono::high_resolution_clock.
|
8 | 8 | // The unit should be one of the duration types provided in std::chrono,
|
9 | 9 | // e.g. seconds, microseconds, etc.
|
10 |
| -#define REGISTER_TIMER(name, unit) \ |
11 |
| - static std::chrono::high_resolution_clock::time_point name ## _clock_start; \ |
12 |
| - static std::chrono::high_resolution_clock::time_point name ## _clock_stop; \ |
13 |
| - void name ## _timer_start() { \ |
14 |
| - name ## _clock_start = std::chrono::high_resolution_clock::now(); \ |
15 |
| - } \ |
16 |
| - void name ## _timer_stop() { \ |
17 |
| - name ## _clock_stop = std::chrono::high_resolution_clock::now(); \ |
18 |
| - } \ |
19 |
| - uint64_t name ## _timer_measurement() { \ |
20 |
| - return std::chrono::duration_cast<std::chrono::unit>( \ |
21 |
| - name ## _clock_stop - name ## _clock_start).count(); \ |
| 10 | +#define REGISTER_TIMER(name, unit) \ |
| 11 | + static std::chrono::high_resolution_clock::time_point name##_clock_start; \ |
| 12 | + static std::chrono::high_resolution_clock::time_point name##_clock_stop; \ |
| 13 | + void name##_timer_start() { \ |
| 14 | + name##_clock_start = std::chrono::high_resolution_clock::now(); \ |
| 15 | + } \ |
| 16 | + void name##_timer_stop() { \ |
| 17 | + name##_clock_stop = std::chrono::high_resolution_clock::now(); \ |
| 18 | + } \ |
| 19 | + uint64_t name##_timer_measurement() { \ |
| 20 | + return std::chrono::duration_cast<std::chrono::unit>( \ |
| 21 | + name##_clock_stop - name##_clock_start) \ |
| 22 | + .count(); \ |
22 | 23 | }
|
23 | 24 |
|
24 | 25 | #endif // TIMER_H
|
0 commit comments