[fpc-devel] FPC/Delphi/FastMM4/TopMemory speed test

Adem listmember at letterboxes.org
Sat Jul 17 13:25:13 CEST 2010


  And, the code I used was this.

Now, I'd like to ask why every now and then (something like 1 in 10) I 
get a negative value for Time3 under FPC. Delphi never exhibits that 
behavior.

function GetCPUTicks: Int64;
asm
   RDTSC;
end

procedure TForm1.ButtonPerformanceClick(Sender: TObject);
Const
   MAX_COUNT = 1000000;
var
   Node1: TMyNode;
   Index1: integer;
   Time1: Int64;
   Time2: Int64;
   Time3: Int64;
begin
   Node1 := TMyNode.Create(Nil);

   Time1 := GetCPUTicks;

   Index1 := 0;
   while Index1 < MAX_COUNT do begin
     TMyNode.Create(Node1);
     Inc(Index1);
   end;

   Time2 := GetCPUTicks;

   Time3 := Time2 - Time1;

   MemoPerformance.Lines.Add(Format('Time: %n', [Time3 * 1E-6]));
   Node1.Free;
end;



More information about the fpc-devel mailing list