加入收藏  广告服务  关于我们
 2003-9-16

获得代码执行时间

发表:不详   阅读:次  关键字:不详   字体:[ ]

使用Windows API 函数GetTickCount,GetTickCount 函数返回从启动Windows后消逝的毫秒数。如果函数成

功的返回,返回值就是从启动Windows后消逝的毫秒数。

举例如下:

procedure TForm1.Button1Click(Sender: TObject);
Var

i:Longint;

starttime,endtime:Double;

Const clock_tick:double=1000;

Begin

i:=0;

starttime:=GetTickCount;

While (i<10000000) do i:=i+1;

endtime:=GetTickCount-starttime;

ShowMessage(Format('循环执行时间:%0.2f 秒',[endtime/clock_tick]));

End;

 热门文章
 推荐信息