Linux系统下获取从启动到当前的ticks数

来源:赛迪网 作者:sixth
  
#include <sys/times.h>
clock_t times(struct tms *buf);

clock_t就是返回的ticks的值,在一般的linux定义中,它是long的typedef。

 

unsigned long ticks = (unsigned long) times( NULL );

 

ticks的时间精度,如下方法:

 

 

unsigned long HZ = sysconf( _SC_CLK_TCK );

它返回每秒中的ticks个数。

其中_SC_CLK_TCK在文件 unistd.h中定义。

(责任编辑:A6)


时间:2007-10-08 09:52 来源:赛迪网 作者:sixth 原文链接

好文,顶一下
(0)
0%
文章真差,踩一下
(0)
0%
------分隔线----------------------------


把开源带在你的身边-精美linux小纪念品
无觅相关文章插件,快速提升流量