Skip to content

Instantly share code, notes, and snippets.

@sergey-shambir
Last active May 12, 2016 11:06
Show Gist options
  • Save sergey-shambir/a4ca7f302f19789e44d19de75cab94ca to your computer and use it in GitHub Desktop.
Save sergey-shambir/a4ca7f302f19789e44d19de75cab94ca to your computer and use it in GitHub Desktop.
#include <chrono>
int main()
{
// Через системные часы получаем объект типа time_point.
auto timePointBefore = std::chrono::system_clock::now();
RunSomeLongOperation();
// Получаем второй момент времени (после операции).
auto timePointAfter = std::chrono::system_clock::now();
auto timeDeltaMsec = std::chrono::duration_cast<std::chrono::milliseconds>(timePointAfter - timePointBefore);
std::cerr << "Total time: " << timeDeltaMsec.count() << "ms" << std::endl;
return 0;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment