【发布时间】:2012-12-29 12:35:26
【问题描述】:
我在 C++ 中使用 time.h 来测量函数的时间。
clock_t t = clock();
someFunction();
printf("\nTime taken: %.4fs\n", (float)(clock() - t)/CLOCKS_PER_SEC);
但是,我总是将时间设为 0.0000。分开打印时,clock() 和 t 具有相同的值。我想知道是否有办法在 C++ 中精确测量时间(可能是纳秒级)。我用的是VS2010。
【问题讨论】:
-
您可能会遇到Microsoft Minute。
标签: c++ visual-studio-2010 chrono ctime