Skip to content

Instantly share code, notes, and snippets.

@stevensona
Last active May 10, 2016 19:21
Show Gist options
  • Save stevensona/ef31be599d982ec0cc310037545e6b82 to your computer and use it in GitHub Desktop.
Save stevensona/ef31be599d982ec0cc310037545e6b82 to your computer and use it in GitHub Desktop.
c++ timing helper
#include <chrono>
#include <functional>
template<class T>
long long benchmark(std::function<void()> op) {
auto start = std::chrono::steady_clock::now();
op();
return std::chrono::duration_cast<T>(std::chrono::steady_clock::now() - start).count();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment