Computer clock

2

Is it possible to calculate the difference between two separate time registers for less than one second using the computer's clock? For example, between 12h00m00s000ms and 12h00m00s050ms.

    
asked by anonymous 10.10.2014 / 03:47

1 answer

1

Take a look at this: clock_getres, clock_gettime, clock_settime And here: link

int clock_getres(clockid_t clk_id, struct timespec *res);
     

The clock_getres() function finds the resolution (precision) of the specified% clock, and, if clk_id is not res , stores the result in struct NULL pointed to by timespec . Clock resolution depends on the implementation and can not be configured by a particular process. If the time value pointed by the argument res of tp is not a multiple of clock_settime() , then it is truncated to a multiple of res .

int clock_gettime(clockid_t clk_id, struct timespec *tp);
int clock_settime(clockid_t clk_id, const struct timespec *tp);
     

The res and clock_gettime() functions retrieve and assign the time of the% specified% clock.

    
10.10.2014 / 03:59