Skip to content

Instantly share code, notes, and snippets.

@jeromew21
Last active October 4, 2019 21:28
Show Gist options
  • Save jeromew21/28b71cc18b9941f6b7e79424e593aa97 to your computer and use it in GitHub Desktop.
Save jeromew21/28b71cc18b9941f6b7e79424e593aa97 to your computer and use it in GitHub Desktop.
Simple execution timer (C++)
#include <chrono>
/*
* ...
*/
auto start = std::chrono::high_resolution_clock::now();
/*
* do stuff
*/
auto stop = std::chrono::high_resolution_clock::now();
auto duration = std::chrono::duration_cast<std::chrono::nanoseconds>(stop - start); //or milliseconds
unsigned long duration_count = duration.count();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment