码迷,mamicode.com
首页 > 编程语言 > 详细

C语言计算程序运行的时间

时间:2017-06-04 23:00:30      阅读:194      评论:0      收藏:0      [点我收藏+]

标签:span   star   int   sdn   style   time   时间   null   eval   

参考网址:http://blog.csdn.net/trustbo/article/details/10582287


 

#include <</span>stdio.h>
#include <</span>sys/time.h>
 
int main() {
    struct timeval start, end;
    gettimeofday( &start, NULL );
    sleep(3);
    gettimeofday( &end, NULL );
    int timeuse = 1000000 * ( end.tv_sec - start.tv_sec ) + end.tv_usec -start.tv_usec;
    printf("time: %d us\n", timeuse);
    return 0;
}

 

C语言计算程序运行的时间

标签:span   star   int   sdn   style   time   时间   null   eval   

原文地址:http://www.cnblogs.com/hwy89289709/p/6941920.html

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