std::clock()
测量程序持续时间内的时钟滴答数。在下面的代码中,它是否计算CPU时间或挂钟时间?
std :: clock_t开始; 持续时间延长;
start = std::clock();
/* Your algorithm here */
duration = ( std::clock() - start ) / (double) CLOCKS_PER_SEC;
在另一种情况下,使用以下代码:
std::clock_t start;
double time;
start = std::clock();
time = start / (double) CLOCKS_PER_SEC;
时间的价值是多少?
从文档中:
std::clock
时间可能比挂钟快或慢,这取决于操作系统为程序提供的执行资源。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句