[fpc-devel] TFPHashList (Was: Alternative parsers)

Dariusz Mazur darekm at emadar.com
Fri Oct 22 23:17:08 CEST 2010


>>> Benchmarking included 3*10^6 calls to Add and Find methods
>>> with the arguments of various lengths.
>>>
>>> Average string length 5 characters:
>>> ShortString: 1.15 s
>>> AnsiString: 1.56 s
>>>
>>> Average string length 45 characters:
>>> ShortString: 12.0 s
>>> AnsiString: 3.2 s
>>>
>>> I agree that the first case is more relevant for the compiler,
>>> but still you can see that ShortStrings are clearly not always faster.
>>
> Sure, see attachment.
> Note that I made shortstring->ansistring text replacament
> followed by minimal fixed to get working Add and Find methods.
> Other methods may be broken as a result.
>

I've done some some optimizations of tFPHashList and results are (for 
10^6 calls average length 30 characters):
from svn: 2.234s
uhla : 2.297
my : 2.044

that is 10% shorter  (or even better, because string generation consume 
about 1.4s)
full source in attachment (should I prepare it different?)


changes are made in: FPHash and some minor in StrExpand,AddStr, Add

Second: when I review assembler list I've notice some strange lines (all 
optimizations are enabled):

# [124] dec(ii);
     movl    %esi,%eax
     decl    %eax
     movl    %eax,%esi
.Lj16:
     movl    %esi,%eax <-  this is not necessary
     testl    %eax,%eax
     jg    .Lj15

In source this is
while ii>0 do begin
   ..
   dec(ii)
end;


Can be added some optimizations to avoid this doubled move.



-- 
   Darek




-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: uhlm.pas
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20101022/a19ce7f1/attachment.ksh>


More information about the fpc-devel mailing list