面对现实,超越自己
逆水行舟,不进则退
posts - 269,comments - 32,trackbacks - 0
示例代码:
long begin,end;
double time;
begin = clock();
{
     //查看代码
}
end  = clock();
time = (double)(end - begin) / CLOCKS_PER_SEC;
Logger->Info( "%f seconds\n", time );

其他参考:
#include<iostream> 
include<windows.h> 
using namespace std;
int main() 

    DWORD start_time=GetTickCount(); 
    { 
       //此处为被测试代码
     } 
    DWORD end_time=GetTickCount(); 
    cout<<"The run time is:"<<(end_time-start_time)<<"ms!"<<endl;//输出运行时间
    return 0; 
}  

#include<iostream> 
#include<time.h> 
using namespace std;
int main()

   clock_t start_time=clock(); 
   { 
      //被测试代码 
    } 
   clock_t end_time=clock();
   cout<< "Running time is: "<<static_cast<double>(end_time- start_time)/CLOCKS_PER_SEC*1000<<"ms"<<endl;//输出运行时间 
   return 0
posted on 2013-10-22 08:20 王海光 阅读(809) 评论(0)  编辑 收藏 引用 所属分类: C++

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理