Re: String Functions



Hi John,

> The following IntToStr_JH1 function seems to be about
> 4 times faster than IntToStrPLR1 on small integers and
> about the same as IntToStrPLR1 on the largest integers.

I have serious doubts about the validity of that statement. How did you
measure it?

I just did a few tests on a P4:

With input values of +-maxint IntToStrPLR1 is 4.1 times faster.
With completely random integers IntToStrPLR1 is 3.7 times faster.
With integers < 10000 IntToStrPLR1 is about twice as fast.
With integers < 10 they are about the same.

Note that these times take into account the time used to generate the random
numbers and the loop traversal, so the actual difference is even greater.

Here is the benchmark code I used:

function GetTicks: Int64;
asm
rdtsc;
end;

procedure TForm1.Button1Click(Sender: TObject);
var
i: integer;
ticks: Int64;
begin
ticks := getticks;
for i := 1 to 100000 do
begin
IntToStr_JH1(random(10000));
// IntToStrPLR1(random(10000));
end;
ticks := getticks - ticks;
label1.caption := inttostr(ticks div 1000);
end;

Regards,
Pierre


.


Quantcast