概述
#include
// 返回自系统开机以来的毫秒数(tick)
unsigned long GetTickCount()
{
struct timespec ts;
clock_gettime(CLOCK_MONOTONIC, &ts);
return (ts.tv_sec * 1000 + ts.tv_nsec / 1000000);
}
int main()
{
struct timespec time1 = { 0, 0 };
clock_gettime(CLOCK_REALTIME, &time1);
printf("CLOCK_REALTIME: %d, %dn", time1.tv_sec, time1.tv_nsec);
clock_gettime(CLOCK_MONOTONIC, &time1);
printf("CLOCK_MONOTONIC: %d, %dn", time1.tv_sec, time1.tv_nsec);
clock_gettime(CLOCK_MONOTONIC_RAW, &time1);
printf("CLOCK_MONOTONIC_RAW: %d, %dn", time1.tv_sec, time1.tv_nsec);
clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &time1);
printf("CLOCK_PROCESS_CPUTIME_ID: %d, %dn", time1.tv_sec,
time1.tv_nsec);
clock_gettime(CLOCK_THREAD_CPUTIME_ID, &time1);
printf("CLOCK_THREAD_CPUTIME_ID: %d, %dn", time1.tv_sec,
time1.tv_nsec);
printf("n%dn", time(NULL));
printf("tick count in ms: %uln", GetTickCount());
return 0;
}
(原文:http://blog.csdn.net/guang11cheng/article/details/6865992)
最后
以上就是俭朴金鱼为你收集整理的linux tick 函数,Linux上的GetTickCount函数的全部内容,希望文章能够帮你解决linux tick 函数,Linux上的GetTickCount函数所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复