Skip to content

Instantly share code, notes, and snippets.

@hertzsprung
Last active September 10, 2019 13:43
Show Gist options
  • Save hertzsprung/f46728daad35b41b7598f773c17159d4 to your computer and use it in GitHub Desktop.
Save hertzsprung/f46728daad35b41b7598f773c17159d4 to your computer and use it in GitHub Desktop.
C++ timers
// adapted from https://stackoverflow.com/a/32241080/150884
#include <chrono>
#include <iostream>
using Clock = std::chrono::high_resolution_clock;
auto t1 = Clock::now();
// do stuff
auto t2 = Clock::now();
std::cout << std::chrono::duration_cast<std::chrono::milliseconds>(t2-t1).count() << "ms" << std::endl;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment