[fpc-pascal] AnsiStrings and Memory Management

Adrian Veith adrian at veith-system.de
Thu Dec 15 14:14:58 CET 2005


Florian Klaempfl schrieb:
> Adrian Veith wrote:
>
>   
>> Hi,
>>
>> two days ago i posted a comment about my experiences porting our
>> database server to fpc. yesterday i tried to figure out where the speed
>> differences between delphi and fpc come from. At the moment i stuck a
>> little bit, because the results i get don't make any sense at the moment
>> to me.
>> Anyway i dropped over another problem, which might be part of the cause
>> of my problems. I tried to create a test base for my investigations and
>> created a function NumberToText which converts an integer to written
>> text  (like NumberToText(1234) -> "one thousand two hundred thirty
>> four"). When I filled my database with these generated strings I found
>> some significant speed differences between delphi and fpc (over factor
>> 10), which made me curious. According to your comments about my first
>> posting, i suspected the Memory Manager and created three different
>> versions of this NumberToText function and three test loops which each
>> calls the according NumberToText function for 0..999999. Here are the
>> results for fpc and delphi (w and w/o FastMM4)
>>
>> Test1 uses "optimized" string concatention which avoids heap fragmentation
>>     
>
> Did you try/have an unoptimized version? FPC doesn't need these
> optimizations, I fear they hurt only.
>   

the example includes two "optimized" and one unoptimized version. the 
first "optimized" version is the fasted for fpc 2.0.2 (about 2 times) 
but in delphi it has no effect.
But you are completely right for the fpc 2.1.1 version which I just 
tried out - and I am very pleased. Here are the results:

Test1:
   fpc:  3.1 sec - factor = 1.34
   delphi (standard MM): 3.1 sec - factor = 1.34
   delphi (FastMM4): 2.3 sec - factor = 1

Test2:
   fpc: 2.8  sec - factor =  1.47
   delphi (standard MM): 2.9 sec - factor = 1.52
   delphi (FastMM4): 1.9 sec - factor = 1

Test3:
   fpc:  2.5 sec - factor = 1,19
   delphi (standard MM): 3.4 sec - factor = 1.61
   delphi (FastMM4): 2.1 sec - factor = 1


the increase in speed is remarkable !!!




More information about the fpc-pascal mailing list