首页 > 其他 > 详细

效率测试-----时间函数(毫秒级)

时间:2014-09-02 19:43:05      阅读:247      评论:0      收藏:0      [点我收藏+]

测试机器处理效率,或者做效率优化的适合:

 1 #include <time.h>
 2 #include <sys/time.h>
 3 void getCurrentTime(char* buf)    
 4 {   
 5    struct timeval tv;  
 6  
 7    struct timezone tz; 
 8  
 9    struct tm         *p;
10 
11    gettimeofday(&tv,&tz);
12     
13    p = localtime(&tv.tv_sec);  
14 
15    sprintf(buf,"time_now:%d-%d-%d %d:%d:%d.%ld\n", 1900+p->tm_year, 1+p->tm_mon, p->tm_mday, p->tm_hour, p->tm_min, p->tm_sec, tv.tv_usec/1000);  
16 }  

 

效率测试-----时间函数(毫秒级)

原文:http://www.cnblogs.com/cy568searchx/p/3951874.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!