Created
April 2, 2019 06:42
-
-
Save Chillee/c729ac9d1995665ea9426226c4203ca5 to your computer and use it in GitHub Desktop.
Benchmarking utilities
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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