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();
More input, exceptions and threads commands
- Read a file line by line
- Read a line from the keyboard
- Handle exceptions
- Run code on another thread
- Compute a value in the background
- Share a counter between threads
All input, exceptions and threads commands · C++ 23 cheatsheet