点击这里给我发消息 点击这里给我发消息

C语言中计算程序时间的方法

添加时间:2013-12-7
    相关阅读: 程序 C语言

void time_one()
    {
     LARGE_INTEGER one;
     LARGE_INTEGER two;
     LARGE_INTEGER freq;
     QueryPerformanceFrequency(&freq);
     QueryPerformanceCounter(&one);
     for (int i = 0; i < 1000000000; i++)
     {
     }
     QueryPerformanceCounter(&two);
     cout << two.QuadPart * 1.0 / freq.QuadPart - one.QuadPart * 1.0 / freq.QuadPart << endl;
    }

    void time_two()
    {
     double timeStart = GetTickCount();
     for (int i = 0; i < 10000000; i++)
     {
     }
     double timeEnd = GetTickCount();
     cout << timeEnd - timeStart << endl;
    }

    void time_three()
    {
     time_t stime;
     time_t etime;
     time(&stime);
     getchar();
     time(&etime);
     printf(\"%ld\\n\",etime - stime);
    }

    void time_four()
    {
     double begin=(double)clock()/CLK_TCK;
     for (int i = 0; i < 1000000000; i++)
     {
     }
     double end=(double)clock()/CLK_TCK;
     cout << end - begin << endl;
    }

    void time_five()
    {
         clock_t t1 = clock();
         for (int i = 0; i < 1000000000; i++)
     {
     }
        clock_t t2 = clock();
         cout<<\"Total time = \"<<t2-t1<<endl;
    }

相关C语言中计算程序时间的方法

咨询热线:020-85648757 85648755 85648616 0755-27912581 客服:020-85648756 0755-27912581 业务传真:020-32579052
广州市网景网络科技有限公司 Copyright◎2003-2008 Veelink.com. All Rights Reserved.
广州商务地址:广东省广州市黄埔大道中203号(海景园区)海景花园C栋501室
= 深圳商务地址:深圳市宝源路华丰宝源大厦606
研发中心:广东广州市天河软件园海景园区 粤ICP备05103322号 工商注册