C++ 23 · Input, exceptions and threads

Time a section of code

Measure elapsed time with a steady clock.

auto start = std::chrono::steady_clock::now();
work();
auto ms = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::steady_clock::now() - start).count();

Official C++ 23 documentation

More input, exceptions and threads commands

All input, exceptions and threads commands · C++ 23 cheatsheet

Was this page helpful?