我正在使用 Visual Studio 2013,我需要找出我的代码(C++)的执行时间。无论如何,有什么让我这样做吗?
最佳答案
这可能是可能的答案之一:
对于Visual Studio
:转到
工具/选项/项目和解决方案/VC++ 项目设置
并将构建计时
选项设置为“yes
”。之后每次构建的时间将显示在输出窗口中。
对于C
#include <time.h>
int main(void)
{
clock_t tStart = clock();
/* Do your stuff here */
printf("Time taken: %.2fs\n", (double)(clock() - tStart)/CLOCKS_PER_SEC);
return 0;
}
对于C++
对于C++11
关于c++ - 如何打印我的代码的执行时间?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31905157/