打印本文 打印本文 关闭窗口 关闭窗口
Integer GUID和Comb做主键的效率测试(Delphi+access)(二)
作者:武汉SEO闵涛  文章来源:敏韬网  点击数4089  更新时间:2009/4/23 18:25:46  文章录入:mintao  责任编辑:mintao
  private

    { Private declarations }

    procedure InsertComb(cc : integer);

    procedure InsertComb2(cc : integer);

    procedure InsertGuid(cc : integer);

    procedure insertInt(cc : integer);

  public

    { Public declarations }

  end;

 

 

 

var

  Form1: TForm1;

 

 

 

implementation

 

 

 

{$R *.dfm}

 

 

 

procedure TForm1.Button1Click(Sender: TObject);

var

 TotalTime : Cardinal;

 cc : integer;

begin

cc:= strtoint(Edit1.Text);

TotalTime := GetTickCount;

insertInt(cc);

TotalTime := GetTickCount - TotalTime;

Label3.Caption := inttostr(TotalTime);

 

 

 

TotalTime := GetTickCount;

InsertGuid(cc);

TotalTime := GetTickCount - TotalTime;

Label5.Caption := inttostr(TotalTime);

 

 

 

TotalTime := GetTickCount;

InsertComb(cc);

TotalTime := GetTickCount - TotalTime;

Label7.Caption := inttostr(TotalTime);

 

 

 

TotalTime := GetTickCount;

InsertComb2(cc);

TotalTime := GetTickCount - TotalTime;

Label9.Caption := inttostr(TotalTime);

end;

 

 

 

procedure TForm1.InsertComb(cc : integer);

var

  i : integer;

begin

  ADOCommand1.CommandText :=''''Insert into TComb(PComb,NInt) values(:PComb,:NInt)'''';

  ADOCommand1.Prepared := true;

  For i:= 0 to cc-1 do

  begin

     ADOCommand1.Parameters[0].Value := SSystem.GetGuidString(SSystem.GetCombGUID(),'''''''','''''''','''''''');

     ADOCommand1.Parameters[1].Value := i/7;

     ADOCommand1.Execute;

  end;

 

 

 

end;

 

 

 

procedure TForm1.InsertComb2(cc: integer);

var

  i : integer;

  //combStr : string;

begin

  ADOCommand1.CommandText :=''''Insert into TComb2(PComb,NInt) values(:PComb,:NInt)'''';

  ADOCommand1.Prepared := true;

  For i:= 0 to cc-1 d

上一页  [1] [2] [3] [4]  下一页

打印本文 打印本文 关闭窗口 关闭窗口