I am just learning how to use clock_getres (there is almost no good documentation for this anywhere on the web). My code looks like this:
timespec now;
clock_getres(CLOCK_REALTIME,&now);
std::cout<<statut_cast<int>(now.tv_sec)<<","<<static_cast<int>(now.tv_nsec)<<std::endl;
No matter when I run this code, the output is always 0,1
Can anybody explain why this doesn’t work?
Use
clock_gettimeto return the current time, notclock_getres, which returns the resolution of the clock.http://pubs.opengroup.org/onlinepubs/009604599/functions/clock_getres.html: