#include
#include
#include
/*
* gcc -Wall -lrt -o timerResolution timerResolution.c
*
*/
int main()
{
clockid_t clocks[] = {
CLOCK_REALTIME,
CLOCK_MONOTONIC,
CLOCK_PROCESS_CPUTIME_ID,
CLOCK_THREAD_CPUTIME_ID,
(clockid_t)-1
};
int i;
{
long hz;
hz = sysconf(_SC_CLK_TCK);
if(hz==-1) {
perror("sysconf");
} else {
printf("hz = %ld\n", hz);
}
}
for(i=0; clocks[i]!=(clockid_t)-1; i++) {
struct timespec res;
int ret;
ret = clock_getres( clocks[i], &res);
if(ret) {
perror("clock_getres");
} else {
printf("clock=%d sec=%ld nsec=%ld\n", clocks[i], res.tv_sec, res.tv_nsec);
}
}
return 0;
}
0 件のコメント:
コメントを投稿