Every embedded application interacting with peripheral hardware or responding to external events has to deal with timeouts and reaction times. To do this properly, developers need the ability to measure time intervals with sufficient precision.
The C++ Chrono library provides an std::chrono::duration templated class for handling durations of arbitrary span and precision. In this recipe, we will learn how to use this class to measure the time interval between two timestamps and check it against a reference duration.