bhupixb

Time It

Feb 9th, 2020
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.44 KB | None | 0 0
  1.  
  2. struct timeit {
  3. decltype(chrono::high_resolution_clock::now()) begin;
  4. const string label;
  5. timeit(string label = "???") : label(label) { begin = chrono::high_resolution_clock::now(); }
  6. ~timeit() {
  7. auto end = chrono::high_resolution_clock::now();
  8. auto duration = chrono::duration_cast<chrono::milliseconds>(end - begin).count();
  9. cerr << duration << "ms elapsed [" << label << "]" << endl;
  10. }
  11. };
Add Comment
Please, Sign In to add comment