[fpc-pascal] Is the TFPGMap.KeyData()/TDictionary.TryGetValue() faster than TStringList.Values[]?

silvioprog silvioprog at gmail.com
Thu Jan 14 03:34:02 CET 2016


I need two fast list features:

Add(Key: string, Value: string);
Get(Key: string, Value: string): string;

So, I took a look at the `TFPGMap` (and `TDictionary` on Delphi) class. It
is really a very nice option. But I tested the `TStringList` class too, and
I was suprised with its performance. Please, run this small test in your
environment (my env. is: FPC 3.1.1 / Delphi Seattle, both generating a 32
bits EXE):


FPC result:

TStringList: 00:00:14.988
TMyList: 00:00:00.187
TMyList: 00:00:00.219
TStringList: 00:00:15.204
Press [ENTER] to exit ...

*(Delphi result:*
*TStringList: 00:00:10.859*
*TMyList: 00:00:00.016*
*TMyList: 00:00:00.003*
*TStringList: 00:00:11.453*
*Press [ENTER] to exit ...**)*

Is this test wrong, or is the `TStringList.Values[]` really slow?

Thank you!

Silvio Cl├ęcio
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20160113/7a34030e/attachment.html>

More information about the fpc-pascal mailing list