您的位置:首页 > 其它

计算程序运行时间,精确到毫秒级

2015-08-03 10:22 295 查看
#include <sys/timeb.h>

#if defined(WIN32)

# define  TIMEB    _timeb

# define  ftime    _ftime

#else

#define TIMEB timeb

#endif

time_t ltime1, ltime2, tmp_time;

  struct TIMEB tstruct1, tstruct2;

  

  ftime (&tstruct1);            // start time ms

  time (<ime1);               // start time s

  //work

  time (<ime2);               // end time sec

  ftime (&tstruct2);            // end time ms

  tmp_time = (ltime2 * 1000 + tstruct2.millitm) - (ltime1 * 1000 + tstruct1.millitm);
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: