C
coolrain
Unregistered / Unconfirmed
GUEST, unregistred user!
一段程序,不知是何故,编译能通过,运行时总是出现 cpu的调试窗口。
求大家帮我看看。
是一个计算优化变体数组时间的程序。
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, ComCtrls;
type
TintArray=Array[1..1000000] of integer;
PIntArray=^TIntArray;
type
TForm1 = class(TForm)
UnLkTm: TEdit;
LkTm: TEdit;
AryBound: TEdit;
Button1: TButton;
StsBar: TStatusBar;
ArrayNum: TLabel;
UnlockTime: TLabel;
LockTime: TLabel;
Button2: TButton;
procedure Button1Click(Sender: TObject);
private
FVarintCount:integer;
FvarAry:variant;
{ Private declarations }
public
function CountWriteTime(AvalueIntArray):dword;
end;
var
Form1: TForm1;
PVarAryIntArray;
implementation
{$R *.DFM}
{ TForm1 }
function TForm1.CountWriteTime(Avalue: PIntArray): dword;
var Index:integer;
T1,T2word;
begin
T1:=GetTickCount;
for Index:=0 to FvarintCount do
begin
Avalue^[Index]:=Index;
end;
T2:=GetTickCount;
Result:=T2-T1;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
try
FvarintCount:=StrToInt(AryBound.Text);
except
StsBar.SimpleText:='conver error!';
exit;
end;
FvarAry:=VarArrayCreate([0,FvarintCount],varinteger);
try
PVarAry:=varArrayLock(FvarAry);
LkTm.Text:=FloatToStr(CountWriteTime(PvarAry));
finally
varArrayUnlock(FvarAry);
VarClear(FvarAry);
end;
end;
end.
求大家帮我看看。
是一个计算优化变体数组时间的程序。
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, ComCtrls;
type
TintArray=Array[1..1000000] of integer;
PIntArray=^TIntArray;
type
TForm1 = class(TForm)
UnLkTm: TEdit;
LkTm: TEdit;
AryBound: TEdit;
Button1: TButton;
StsBar: TStatusBar;
ArrayNum: TLabel;
UnlockTime: TLabel;
LockTime: TLabel;
Button2: TButton;
procedure Button1Click(Sender: TObject);
private
FVarintCount:integer;
FvarAry:variant;
{ Private declarations }
public
function CountWriteTime(AvalueIntArray):dword;
end;
var
Form1: TForm1;
PVarAryIntArray;
implementation
{$R *.DFM}
{ TForm1 }
function TForm1.CountWriteTime(Avalue: PIntArray): dword;
var Index:integer;
T1,T2word;
begin
T1:=GetTickCount;
for Index:=0 to FvarintCount do
begin
Avalue^[Index]:=Index;
end;
T2:=GetTickCount;
Result:=T2-T1;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
try
FvarintCount:=StrToInt(AryBound.Text);
except
StsBar.SimpleText:='conver error!';
exit;
end;
FvarAry:=VarArrayCreate([0,FvarintCount],varinteger);
try
PVarAry:=varArrayLock(FvarAry);
LkTm.Text:=FloatToStr(CountWriteTime(PvarAry));
finally
varArrayUnlock(FvarAry);
VarClear(FvarAry);
end;
end;
end.