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

C_测试代码运行时间

时间:2018-09-25 21:10:11      阅读:198      评论:0      收藏:0      [点我收藏+]

标签:cond   image   inf   print   i++   .com   delay   lock   unsigned   

 

 

  

 

#include<stdio.h>
#include<stdlib.h>
#include<time.h>

//测试for循环时间 
void delay(unsigned int t)
{
        unsigned int i,j;
        for(i=0;i<t;i++)
            for(j=0;j<t;j++)
            ;
}

int main( )
{

    clock_t start, finish;
    double Text_time;
    start = clock();
    delay(1000);
    finish = clock();
    Text_time = (double)(finish-start) / CLOCKS_PER_SEC;
    printf("%lf seconds/n", Text_time);
    return 0;
}

 

 

技术分享图片

 

C_测试代码运行时间

标签:cond   image   inf   print   i++   .com   delay   lock   unsigned   

原文地址:https://www.cnblogs.com/1138720556Gary/p/9703470.html

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