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

Alexander Klenin klenin at gmail.com
Wed Oct 20 09:23:08 CEST 2010


On Wed, Oct 20, 2010 at 05:36, Michael Van Canneyt
<michael at freepascal.org> wrote:
> On Wed, 20 Oct 2010, Alexander Klenin wrote:
>> On Wed, Oct 20, 2010 at 01:45, Michael Van Canneyt
>> <michael at freepascal.org> wrote:
>>> Try and improve that class with ansistrings. If you succeed, only then we
>>> can start making a case for using them in the compiler.
>>
>> Ok, I went ahead and have taken look at the code.
>> I assume you speak about TFPHashList vs TFPCustomHashTable.
>> The classes are not really comparable, because they use quite
>> different internal data structures.
>
> But they perform the same function; hash on string with an
> associated data structure.

Sure, but in a very different manner.
Look at the code yourself if you do not believe me ;-)

>> 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.
>
> I'm always open for benchmark tests.
>
> Can you please send me your test and the implementation ?
> I'd like to see when the balance shifts.

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.

-- 
Alexander S. Klenin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ansi_hashlist.7z
Type: application/octet-stream
Size: 3458 bytes
Desc: not available
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20101020/dc304e36/attachment.obj>


More information about the fpc-devel mailing list