【发布时间】:2012-10-17 05:15:35
【问题描述】:
可能重复:
How can I get the execution time of a program in milliseconds in C?
Calculating time of execution with time() function
我在time.h 中尝试了clock(),但它总是给我0.0000 秒,即0 秒作为输出。有没有办法以微秒或毫秒或任何其他更小的单位获得执行时间?
【问题讨论】:
-
应该可以。向我们展示您的代码。
-
你的操作系统是什么?也许您的程序运行得如此之快,以至于时间粒度要大得多。您应该更改您的程序(可能添加循环)以使其运行大约一秒钟。
标签: c