Skip to content

Instantly share code, notes, and snippets.

@zorchp
Last active August 11, 2023 11:17
Show Gist options
  • Save zorchp/b42d7fa678dc77b06c2ef0cb7561b5fe to your computer and use it in GitHub Desktop.
Save zorchp/b42d7fa678dc77b06c2ef0cb7561b5fe to your computer and use it in GitHub Desktop.
for-record-time-spent
#include <chrono>
using namespace std;
using namespace std::chrono;
auto start = system_clock::now();
// do something...
auto end = system_clock::now();
auto duration = duration_cast<microseconds>(end - start);
cout << "Time spent: "
<< double(duration.count()) * microseconds::period::num /
microseconds::period::den
<< "s" << endl;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment