Skip to content

Instantly share code, notes, and snippets.

@Chillee
Created April 2, 2019 06:42
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 Chillee/c729ac9d1995665ea9426226c4203ca5 to your computer and use it in GitHub Desktop.
Save Chillee/c729ac9d1995665ea9426226c4203ca5 to your computer and use it in GitHub Desktop.
Benchmarking utilities
struct timeit {
decltype(chrono::high_resolution_clock::now()) begin;
const string label;
timeit(string label = "???") : label(label) { begin = chrono::high_resolution_clock::now(); }
~timeit() {
auto end = chrono::high_resolution_clock::now();
auto duration = chrono::duration_cast<chrono::milliseconds>(end - begin).count();
cerr << duration << "ms elapsed [" << label << "]" << endl;
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment