From fdf5ef27fec1368a33801a98bbc5ed3556476979 Mon Sep 17 00:00:00 2001 From: Douglas Rumbaugh Date: Mon, 8 May 2023 12:59:46 -0400 Subject: Began porting source files over from other repository --- include/util/timer.h | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 include/util/timer.h (limited to 'include/util/timer.h') 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 + * + * All rights reserved. Published under the Modified BSD License. + * + */ +#pragma once + +#include + +#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(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 + -- cgit v1.2.3