Util for logging exec time.

This commit is contained in:
Kishore Nallan 2016-10-02 19:11:59 +05:30
parent 9d5a120dab
commit d8eee0d04a

17
include/exectime.h Normal file
View File

@ -0,0 +1,17 @@
#pragma once
#include <iostream>
#include <chrono>
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::microseconds>(
std::chrono::high_resolution_clock::now() - begin).count();
std::cout << "Time taken for " << operation << ": " << timeMicros << "us" << std::endl;
}
};