首页 > 其他 > 详细

C_测试代码运行时间

时间:2018-09-25 21:01:58      阅读:143      评论:0      收藏:0      [点我收藏+]

 

 

  

 

#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_测试代码运行时间

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

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