码迷,mamicode.com
首页 > 其他好文 > 详细

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

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

标签:style   blog   color   ar   div   sp   log   amp   on   

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

 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 }  

 

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

标签:style   blog   color   ar   div   sp   log   amp   on   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!