In order to measure the time duration while my app is running, as well as the time that passed while my app was idle in the background, I need a reference clock that is not
#include into your source file.
#include
replace any calls to clock_gettime(CLOCK_MONOTONIC, ×pec_t) with calls to mach_absolute_time().
clock_gettime(CLOCK_MONOTONIC, ×pec_t)
mach_absolute_time()