glorylandhyf

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

2013年5月10日

摘要: 转自:http://blog.jeoygin.org/2012/03/c-get-time-millisecond.html在做测试或性能优化时,经常要知道程序运行的时间,在Linux系统可以使用time命令来计算程序运行运行所消耗的时间,能精确到毫秒,如果要精 确到代码块或某个操作运行时所消耗的时间,time命令就不给力了。如果对时间的精度要求不高的话,可以调用标准C的接口time来得到开始和结束的时 间,再调用difftime接口来计算时间差,精度是秒,代码如下所示:下载: time.c#include <stdio.h>#include <time.h>intma 阅读全文
posted @ 2013-05-10 15:41 glorylandhyf 阅读(946) 评论(0) 推荐(0) 编辑