Back
Close

Modern C++ idoms and recipes

meshell
57.5K views

Measure Time Intervals

C++11 provides a flexible date and time library as part of the standard library that allows to define time points and time intervals. The library is called chrono and is available in the <chrono> header in the std::chrono namespace.

Exercise

Write a method which measures the execution time of a function

Time intervals

Exercise

Define the durations and intervals (i.e. do the TODOs)

Bonus exercise

Define user defined literals for day/days and week/weeks and use them together with the chrono literals to define the intervals in the exercise above.

Create your playground on Tech.io
This playground was created on Tech.io, our hands-on, knowledge-sharing platform for developers.
Go to tech.io