#1 2023-12-07 05:44:44

TPrami
Member
Registered: 2010-07-06
Posts: 116

IntrToStr algorithm (Interesting read)

Offline

#2 2023-12-07 20:21:42

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,549
Website

Re: IntrToStr algorithm (Interesting read)

I am dubious this article is very accurate.
Speaking of 'integer division' for a division per a constant on a recent compiler, in the context of performance is wrong.
Any good compiler (gcc, clang, FPC but not Delphi) is able to replace a " x / 10 " with a multiplication with the 32-bit or 64-bit reciprocal.

I do not see how its implementation may be faster than our StrUInt32() or StrUInt64() asm for i386 or x86_64.
In the context of pascal, the real bottleneck of IntToStr() is not the text computation, it is the string allocation.

Offline

#3 2023-12-08 08:47:43

TPrami
Member
Registered: 2010-07-06
Posts: 116

Re: IntrToStr algorithm (Interesting read)

ab wrote:

I am dubious this article is very accurate.
Speaking of 'integer division' for a division per a constant on a recent compiler, in the context of performance is wrong.
Any good compiler (gcc, clang, FPC but not Delphi) is able to replace a " x / 10 " with a multiplication with the 32-bit or 64-bit reciprocal.

I do not see how its implementation may be faster than our StrUInt32() or StrUInt64() asm for i386 or x86_64.
In the context of pascal, the real bottleneck of IntToStr() is not the text computation, it is the string allocation.

True.

Don't know how that algorithm would perform, I would say just by reading the article and looking at Delphi implementation.

My gut feeling is that the speed up promises of that article are way too large. Donät understand C/C++ enough that I could port that code to Delphi/Object Pascal.

-Tee-

Offline

Board footer

Powered by FluxBB