C/C++ 计时

来源:互联网 发布:windows rt连接口 编辑:程序博客网 时间:2024/05/16 19:40

#include<time.h>


timespec start,end;


clock_gettime(CLOCK_MONOTONIC,&start);

....

clock_gettime(CLOCK_MONOTONIC,&end);


time=(end.tv_sec-start.tv_sec)*10^9 + end.tv_nsec - start.tv_nsec;(纳秒)