Re: String Functions
- From: "John Herbster" <herb-sci1_AT_sbcglobal.net>
- Date: Sat, 30 Apr 2005 12:55:59 -0500
"Pierre le Riche" <pleriche@xxxxxxxxxxx> wrote
> 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.
> Here is the benchmark code I used:
> 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;
Here below are my results for code similar to the above
with the results converted to TSC counts per conversion.
Note what happens if the number of repeats is reduced
to just 1 (near bottom of post). I think that this the key to
the observed differences --JohnH
Athlon, 1.5Ghz, D7, Win2K
NbrRepeats = 100000; Random(10000);
With Pierre's Code:
260 Random+IntToStrPLR1
585 Random+IntToStr_JH1
260 Random+IntToStrPLR1
585 Random+IntToStr_JH1
Removed the times required for loop random():
230 IntToStrPLR1
578 IntToStr_JH1
229 IntToStrPLR1
581 IntToStr_JH1
Added assignment of result to a string:
230 IntToStrPLR1 771
590 IntToStr_JH1 537
230 IntToStrPLR1 8853
589 IntToStr_JH1 2928
With NbrRepeats = 1; Random(10000);
8363 IntToStrPLR1 0
2672 IntToStr_JH1 313
8179 IntToStrPLR1 8610
2900 IntToStr_JH1 2025
With NbrRepeats = 1; Random(10);
8030 IntToStrPLR1 0
2301 IntToStr_JH1 0
8076 IntToStrPLR1 8
2450 IntToStr_JH1 2
.
- Follow-Ups:
- Re: String Functions
- From: Pierre le Riche
- Re: String Functions
- References:
- String Functions
- From: Chekcin
- Re: String Functions
- From: Dennis
- Re: String Functions
- From: Florent Ouchet
- Re: String Functions
- From: John Herbster
- Re: String Functions
- From: Pierre le Riche
- String Functions
- Prev by Date: Re: String Functions
- Next by Date: Re: String Functions
- Previous by thread: Re: String Functions
- Next by thread: Re: String Functions
- Index(es):