再告诉你一个精度为微秒级的计时方法: <br>unit Unit1; <br><br>interface <br><br>uses <br> Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, <br> Dialogs, StdCtrls, Buttons; <br><br>type <br> TForm1 = class(TForm) <br> Edit1: TEdit; <br> BitBtn1: TBitBtn; <br> Label1: TLabel; <br> Button1: TButton; <br> Edit2: TEdit; <br> Label2: TLabel; <br> Label3: TLabel; <br> Edit3: TEdit; <br> procedure BitBtn1Click(Sender: TObject); <br> procedure Button1Click(Sender: TObject); <br> private <br> { Private declarations } <br> public <br> TimeB, TimeE: Int64; //开始时间,结束时间 <br> end; <br><br>var <br> Form1: TForm1; <br><br>implementation <br><br>{$R *.dfm} <br><br>procedure TForm1.BitBtn1Click(Sender: TObject); <br>var <br> F: Int64; //频率 <br>begin <br> QueryPerformanceCounter(TimeE); //计时结束 QueryPerformanceCounter() 获得当前时钟经过的振动数 <br><br> QueryPerformanceFrequency(F); //时钟频率 <br> Edit1.Text := IntToStr(F); <br><br> Edit2.Text := FloatToStr((TimeE - TimeB)/F*1000000); //计时时长(微秒) <br> Edit3.Text := FloatToStr((TimeE - TimeB)/F); // 计时时长(秒) <br>end; <br><br>procedure TForm1.Button1Click(Sender: TObject); <br>begin <br> QueryPerformanceCounter(TimeB); //计时开始 <br> Edit2.Text := '0'; <br> Edit3.Text := '0'; <br>end; <br><br>end.