Re: Faster way of making long string?



> "Ekkehard Domning" <edo@xxxxxxxx> wrote in message
>
> I made a test (source below) and the result for D4 on my poor computer is
> 57ms to 32s (!).
>
> So be lucky to have a newer delphi and use the suggested fast routine :-)

Hi Ekkehard,

I've found that the comparative speeds (ie. how much worse CommaText is than
other methods) seems to differ from computer to computer and think this is a
bigger factor than which compiler was used.

In my testing TStringList.CommaText produced *inconsistent* speeds from one
test to another, even on the same computer. eg. it might be faster if the
computer has recently been started up than if the computer has been running
programs all day.
This may indicate that the CommaText method is far more susceptible (in
terms of performance) to fragmented memory on account of it having to
allocate new large strings every loop.
But I'm glad you tested it yourself since I later got some much worse
results from it after having posted my first results.

This issue raised about code maintainability and clarity is outside of the
scope of my original post which was directed purely at questioning the
efficiency of strOut := strOut + 'blah' in the context of a large number of
loops. I feel my original suspicions about it have now been well and truly
proven valid.
In any case, I'm going to use the code for adding a "CommaText" method to a
TIntegerList class that I have written and maintain for my personal usage,
so the complexity will not appear in the body of main program code anyway.

Regards,
Ian.


.


Quantcast