Time Duration

The time duration is a measure of how many ticks have passed since a certain time point. The implementation is presented in this lesson.

We'll cover the following...

Time duration

Time duration is the difference between the two time-points. Time duration is measured in the number of ticks.

Press + to interact
template <class Rep, class Period = ratio<1>> class duration;

If Rep is a floating-point number, the time duration supports fractions of ticks. The most important time durations are predefined in the chrono library:

Press + to interact
typedef duration<signed int, nano> nanoseconds;
typedef duration<signed int, micro> microseconds;
typedef duration<signed int, milli> milliseconds;
typedef duration<signed int> seconds;
typedef duration<signed int, ratio< 60>> minutes;
typedef duration<signed int, ratio<3600>> hours;

How long can a time duration be? The C++ standard guarantees that the predefined time durations can store +/- 292 ...