[fpc-devel] FPC/Delphi/FastMM4/TopMemory speed test
David W Noon
david.w.noon at ntlworld.com
Sat Jul 17 14:02:10 CEST 2010
On Sat, 17 Jul 2010 14:25:13 +0300, Adem wrote about Re: [fpc-devel]
FPC/Delphi/FastMM4/TopMemory speed test:
> 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
On a 64-bit system, the return value is in RDX, whereas the RDTSC
instruction returns its value in EDX:EAX on both 32-bit and 54-bit
systems. This means that your returned value will sometimes contain
junk bits, and on other occasions will contain zero bits, when compiled
for a 64-bit binary.
Here is the code I use to collect timestamps:
============================= tsc.pas ==================================
unit tsc;
{ Unit to access the timestamp counter (TSC) on IA-32 (Pentium and
later) processors. }
{ Copyright (C) 2009, David W. Noon }
{ All rights reserved, }
{ This code is released under the GNU Lesser General Public License
(LGPL). }
interface
function rdtsc: qword;
implementation
{$asmmode att}
function rdtsc: qword; assembler;
asm
rdtsc
movl %eax,__result
movl %edx,__result+4
end;
end.
========================================================================
The above code has been tested in both 32-bit and 64-bit binaries.
--
Regards,
Dave [RLU #314465]
=======================================================================
david.w.noon at ntlworld.com (David W Noon)
=======================================================================
More information about the fpc-devel
mailing list