Skip to content

Instantly share code, notes, and snippets.

@githole
Last active July 25, 2019 21:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save githole/eb1417026598492cbbc032ffc305d64b to your computer and use it in GitHub Desktop.
Save githole/eb1417026598492cbbc032ffc305d64b to your computer and use it in GitHub Desktop.
#include <chrono>
struct TIMER final
{
std::chrono::system_clock::time_point start, end;
const char* str;
TIMER(const char* s) : str(s)
{
start = std::chrono::system_clock::now();
}
~TIMER()
{
end = std::chrono::system_clock::now();
const double elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count();
printf("%s: %f", str, elapsed);
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment