Einzelnen Beitrag anzeigen

Benutzerbild von Boombuler
Boombuler

Registriert seit: 14. Mär 2003
Ort: Osnabrück
244 Beiträge
 
Delphi 2009 Professional
 
#9

Re: Boolean: Welcher Aufruf ist schneller?

  Alt 4. Jan 2005, 12:56
Delphi-Quellcode:
procedure TForm1.CheckBox1Click(Sender: TObject);
var i:Cardinal;
loop:integer;
begin
  i := GettickCount;
  for Loop := 1 to 100000 do
  with CheckBox1 do
    begin
      Button1.Enabled := Checked;
      Button2.Enabled := Checked;
      Button3.Enabled := Checked;
      Button4.Enabled := Checked;
      Button5.Enabled := Checked;
      Button6.Enabled := Checked;

      {...}

      If Checked then
        //mach was
      else
        //mach was anderes
    end;
  showmessage(inttostr(Gettickcount - i));
end;
Result -> 16 mili sek

Delphi-Quellcode:
procedure TForm1.CheckBox1Click(Sender: TObject);
var i:Cardinal;
loop:integer;
b:Boolean;
begin
  i := GettickCount;
  for Loop := 1 to 100000 do
  begin
  B := CheckBox1. Checked;

  Button1.Enabled := B;
  Button2.Enabled := B;
  Button3.Enabled := B;
  Button4.Enabled := B;
  Button5.Enabled := B;
  Button6.Enabled := B;

  end;
  showmessage(inttostr(Gettickcount - i));
end;
Result -> 16 mili sek
  Mit Zitat antworten Zitat