德军总部黑科技大全:在vc6.0中,如何计算一段程序的运行时间,需用到哪些函数

来源:百度文库 编辑:高校问答 时间:2024/04/23 17:49:12

你好,可以用到clock函数,以下直接给你一段使用的例子。

函数名: clock
功 能: 确定处理器时间
用 法: clock_t clock(void);
程序例:

#include <stdio.h>
#include <time.h>
#include <dos.h>

int main(void)
{
clock_t start, end;
start = clock();

delay(2000);

end = clock();
printf("The time was: %f\n", (end - start) / CLK_TCK);

return 0;
}

好运!:)

也可以用API函数:GetTickCount(void);用法和上面的一样,能精确到10ms以内