Reserving/Preallocating associative array?

Gordon me at home.com
Tue Dec 24 15:23:04 PST 2013


Hello Bearophine,

On Tuesday, 24 December 2013 at 23:13:59 UTC, bearophile wrote:
>> Some ides to speed up your code:
>> - Try to use parse instead of split + to!size_t
>> - Try to use byLineFast, in the attach here (the code is not 
>> mine): https://d.puremagic.com/issues/attachment.cgi?id=1305
>> - Try to disable the GC before the associative array creation 
>> and re-enable it when it's built. (This could double your max 
>> memory usage or more). To disable it import GC from 
>> core.memory and call GC.disable; and GC.enable;
>
>
> This code is almost 2.5X faster on my PC (but I am using only 
> 300_000 lines of text):
>

You're just too fast for me...

After incorporating your three suggestions, the entire file (11M 
lines) loads in just 25 seconds (down from 3.5 minutes).

AMAZING!

Many thanks,
  -gordon


More information about the Digitalmars-d mailing list