psimakov@outplay.com wrote:
> I just read a great article by Dave Johnson on comparative performance
> of XML and JSON parsing. It is a very important for anyone doing AJAX.
>
> But the parsing is not the only place where CPU can be wasted. I
> personally consider String Concatenations to be even bigger evil.
>
> Here is test study that shows dramatic performance impact of String
> Concatenations and how to avoid it.
>
> http://www.softwaresecretweapons.com/jspwiki/Wiki.jsp?page=JavascriptStringConcatenation
I would argue that test study is not conclusive. True, string
concatenations can be slow, but how you use them will also affect
performance. In the test study show, you're building a table.
Obviously it would be slow. Have you considered other factors? The
code is no doubt inefficient. For example, it is using two for loops!
That's a O(n^2). Don't forget the initialization of a for loop. Oh
yeah, did you miss the post increment? Would be more efficient if it
was a pre-increment instead. Unless you have written an optimized
code, that study does not accurately show the performance impact of
string concatenations just because there are other factors that are
heavily weighed in (to me anyways).
Received on Sat Dec 3 04:33:48 2005