From d8eee0d04a33d08793448f9b66c4a742068dd643 Mon Sep 17 00:00:00 2001 From: Kishore Nallan Date: Sun, 2 Oct 2016 19:11:59 +0530 Subject: [PATCH] Util for logging exec time. --- include/exectime.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 include/exectime.h diff --git a/include/exectime.h b/include/exectime.h new file mode 100644 index 00000000..3e269eee --- /dev/null +++ b/include/exectime.h @@ -0,0 +1,17 @@ +#pragma once +#include +#include + +class ExecTime { + static auto begin = std::chrono::high_resolution_clock::now(); + + static void start() { + begin = std::chrono::high_resolution_clock::now(); + } + + static void log(std::string operation) { + long long int timeMicros = std::chrono::duration_cast( + std::chrono::high_resolution_clock::now() - begin).count(); + std::cout << "Time taken for " << operation << ": " << timeMicros << "us" << std::endl; + } +}; \ No newline at end of file