cputick2usec() imprecision/timestep could be seen in KERN_PROC_PROC sysctl (struct kinfo_proc field ki_runtime) and in CLOCK_PROCESS_CPUTIME_ID/CLOCK_THREAD_CPUTIME_ID clocks
This program could show the timestep, but it is very time-consuming.
On 4GHz CPU, first timestep will be about 1ms at 76 minutes of consumed cputime, but 1ms step is hard to see because there is many other reasons for such lag. Second step of about 20 minutes will be at 53.4 days cputime.
```
#include <stdio.h>
#include <time.h>
static struct timespec ts, ts2;
static long tsdiff(void) {
long r;
r = ts2.tv_sec-ts.tv_sec;
r *= 1000000000;
r += ts2.tv_nsec;
r -= ts.tv_nsec;
return r;
}
int main(void) {
long d, md;
md = 0;
clock_gettime(CLOCK_PROCESS_CPUTIME_ID,&ts);
while(1) {
clock_gettime(CLOCK_PROCESS_CPUTIME_ID,&ts2);
d = tsdiff();
if(md<d) md=d;
printf("\r%u.%09us diff=%09luns maxdiff=%09luns",
(unsigned)ts.tv_sec,(unsigned)ts.tv_nsec,d,md);
fflush(stdout);
ts = ts2;
}
}
```
cputick2timespec() imprecision shown also by the above program: all values will have three trailing zeroes.