clock()显示自程序启动以来已经过了多少个刻度.宏CLOCKS_PER_SEC包含每秒的滴答数,因此您实际上可以获得时间.
//We start measuring here. Remember what was the amount of ticks in the //beginning of the part of code you want to test:int start = clock();//<...>//Do your stuff here//<...>int end = clock();//Now check what amount of ticks we have Now. //To get the time,just subtract start from end,and divIDe by CLOCKS_PER_SEC.std::cout << "it took " << end - start << "ticks,or " << ((float)end - start)/CLOCKS_PER_SEC << "seconds." << std::endl;总结
以上是内存溢出为你收集整理的C/C++中的算法速度测试仪全部内容,希望文章能够帮你解决C/C++中的算法速度测试仪所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)