diff options
| author | Douglas Rumbaugh <dbr4@psu.edu> | 2023-05-08 12:59:46 -0400 |
|---|---|---|
| committer | Douglas Rumbaugh <dbr4@psu.edu> | 2023-05-08 12:59:46 -0400 |
| commit | fdf5ef27fec1368a33801a98bbc5ed3556476979 (patch) | |
| tree | 7ecd9477fed6495d05a44343e19bfb6480785c7a /include/util/timer.h | |
| parent | 2380dd4d73cd6a179567e06e1aa4871ad44ccce3 (diff) | |
| download | dynamic-extension-fdf5ef27fec1368a33801a98bbc5ed3556476979.tar.gz | |
Began porting source files over from other repository
Diffstat (limited to 'include/util/timer.h')
| -rw-r--r-- | include/util/timer.h | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/include/util/timer.h b/include/util/timer.h new file mode 100644 index 0000000..a9784a8 --- /dev/null +++ b/include/util/timer.h @@ -0,0 +1,37 @@ +/* + * include/util/timer.h + * + * Copyright (C) 2023 Douglas Rumbaugh <drumbaugh@psu.edu> + * + * All rights reserved. Published under the Modified BSD License. + * + */ +#pragma once + +#include <chrono> + +#ifdef ENABLE_TIMER +#define TIMER_INIT() \ + auto timer_start = std::chrono::high_resolution_clock::now(); \ + auto timer_stop = std::chrono::high_resolution_clock::now(); + +#define TIMER_START() \ + timer_start = std::chrono::high_resolution_clock::now() + +#define TIMER_STOP() \ + timer_stop = std::chrono::high_resolution_clock::now() + +#define TIMER_RESULT() \ + std::chrono::duration_cast<std::chrono::nanoseconds>(timer_stop - timer_start).count() + +#else + #define TIMER_INIT() \ + do {} while(0) + #define TIMER_START() \ + do {} while(0) + #define TIMER_STOP() \ + do {} while(0) + #define TIMER_RESULT() \ + 0l +#endif + |