Skip to content

Instantly share code, notes, and snippets.

@byBretema
Last active January 20, 2021 10:14
Show Gist options
  • Save byBretema/3b5ba3f3aa3b73a587c4c8dc70114038 to your computer and use it in GitHub Desktop.
Save byBretema/3b5ba3f3aa3b73a587c4c8dc70114038 to your computer and use it in GitHub Desktop.
Timer Snippet - OOTB
#include <iostream>
#include <string>
#include <chrono>
using Clock = std::chrono::high_resolution_clock;
class Timer {
public:
Timer(std::string const & msg = "") : m_msg(msg), m_iTime(Clock::now()) {}
~Timer() {
std::cout << "["
<< std::chrono::duration<double>(Clock::now() - m_iTime).count()
<< "s] " << m_msg << '\n';
}
private:
std::string m_msg;
Clock::time_point m_iTime;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment