Skip to content

Instantly share code, notes, and snippets.

@hpwxf
Created March 4, 2020 15:58
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 hpwxf/76694a5b6ed8d4052097545f2d9a6125 to your computer and use it in GitHub Desktop.
Save hpwxf/76694a5b6ed8d4052097545f2d9a6125 to your computer and use it in GitHub Desktop.
Time measure using std::chrono
const auto start = std::chrono::system_clock::now();
process(...)
const auto end = std::chrono::system_clock::now();
auto elapsed = [=](auto start, auto end) {
return std::chrono::duration_cast<std::chrono::microseconds>(end - start).count();
};
double duration = static_cast<double>(elapsed(start, end)) / 1000; // as ms
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment