0
我来到这里与籽粒2.6.18 Linux的麻烦,当我试图让纳秒的时间,像这样:clock_gettime得到ns是0
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main(void)
{
struct timespec time_start;
clock_gettime(CLOCK_REALTIME, &time_start);
printf(CLOCK_REALTIME);
printf("\nstart time %llus,%llu ns\n", time_start.tv_sec,time_start.tv_nsec);
return 0;
}
但是当我运行该脚本,它像打印这样的:
[[email protected] test]# ./time
start time 1474529199s,506211000 ns
[[email protected] test]# ./time
start time 1474529200s,65344000 ns
[[email protected] test]# ./time
start time 1474529200s,557196000 ns
只能得到微秒这里,和NS是0
谁能告诉我,为什么它这样的吗?
我的看法是,并非所有的平台都会实现clock_gettime来返回纳秒,所以你运气不好。 – Bathsheba