Re: String Functions




"Pierre le Riche" <pleriche@xxxxxxxxxxx> wrote
> Two problems with your benchmark:

> (1) No negative numbers, so some of the branches
> in your function gets perfectly predicted.

That was because I copied it after the test in the
preceding post. It is however a only a small branch
for the negative numbers, so I do not think that it should
matter much.

> (2) You don't reset the result string back to '' [empty]
> before calling IntToStrXXX.

That was deliberate, in order to mimic ordinary (at least
in my experience) usage of the IntToStr function. That
is also why I ran IntToStrPLR1, then IntToStr_JH1, then
IntToStrPLR1, then IntToStr_JH1 -- just to check on the
effects of string "reuse".

I have included results below.

In my previous benchmarking, of floating point numbers,
I have seen significant differences do to code (and data)
alignment, and I do not believe that these tests address
the alignment issues very well.

Thanks for looking at it. Regards, JohnH

Here are some typical results on Athlon~1.5Ghz, Win2K, D5.

With 100000 repeats with random(10000)
465 IntToStrPLR1 0
1208 IntToStr_JH1 9513
898 IntToStrPLR1 7368
1032 IntToStr_JH1 5089

With 100000 repeats with random(10000)
447 IntToStrPLR1 2478
1226 IntToStr_JH1 7619
899 IntToStrPLR1 6880
1028 IntToStr_JH1 4907

With 1 repeats with random(10)
2259 IntToStrPLR1 4
1358 IntToStr_JH1 8
1384 IntToStrPLR1 6
1770 IntToStr_JH1 3

With 1 repeats with random(10)
1976 IntToStrPLR1 1
1324 IntToStr_JH1 5
1148 IntToStrPLR1 2
1843 IntToStr_JH1 4

Same tests but reordered:

With 100000 repeats with random(10000)
454 IntToStrPLR1 0
664 IntToStrPLR1 9513
961 IntToStr_JH1 7368
988 IntToStr_JH1 5089

With 100000 repeats with random(10000)
449 IntToStrPLR1 2478
669 IntToStrPLR1 7619
974 IntToStr_JH1 6880
1044 IntToStr_JH1 4907

With 1 repeats with random(10)
2306 IntToStrPLR1 4
1376 IntToStrPLR1 8
1303 IntToStr_JH1 6
1684 IntToStr_JH1 3

With 1 repeats with random(10)
2229 IntToStrPLR1 1
1247 IntToStrPLR1 5
1522 IntToStr_JH1 2
1647 IntToStr_JH1 4

Same test with another order

With 100000 repeats with random(10000)
788 IntToStr_JH1 0
1333 IntToStr_JH1 9513
1159 IntToStrPLR1 7368
1228 IntToStrPLR1 5089

With 100000 repeats with random(10000)
788 IntToStr_JH1 2478
1751 IntToStr_JH1 7619
1165 IntToStrPLR1 6880
913 IntToStrPLR1 4907

With 1 repeats with random(10)
1892 IntToStr_JH1 4
1873 IntToStr_JH1 8
2272 IntToStrPLR1 6
1213 IntToStrPLR1 3

With 1 repeats with random(10)
1972 IntToStr_JH1 1
1502 IntToStr_JH1 5
1922 IntToStrPLR1 2
1200 IntToStrPLR1 4

.