<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Benchmarking, HighResTimer and string concatenation</title>
	<atom:link href="http://sitecore.alexiasoft.nl/2008/02/18/benchmarking-highrestimer-and-string-concatenation/feed/" rel="self" type="application/rss+xml" />
	<link>http://sitecore.alexiasoft.nl/2008/02/18/benchmarking-highrestimer-and-string-concatenation/</link>
	<description>All about the web, online marketing, Sitecore, .NET and building sites...</description>
	<lastBuildDate>Tue, 07 Feb 2012 08:09:29 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: interior design living room</title>
		<link>http://sitecore.alexiasoft.nl/2008/02/18/benchmarking-highrestimer-and-string-concatenation/comment-page-1/#comment-209579</link>
		<dc:creator>interior design living room</dc:creator>
		<pubDate>Mon, 17 May 2010 09:32:06 +0000</pubDate>
		<guid isPermaLink="false">http://sitecore.alexiasoft.nl/2008/02/18/benchmarking-highrestimer-and-string-concatenation/#comment-209579</guid>
		<description>Advantageously, the post is actually the sweetest topic on this registry related issue. I fit in with your conclusions and will thirstily look forward to your future updates. Just saying thanks will not just be enough, for the extraordinary clarity in your writing. I will immediately grab your rss feed to stay informed of any updates.</description>
		<content:encoded><![CDATA[<p>Advantageously, the post is actually the sweetest topic on this registry related issue. I fit in with your conclusions and will thirstily look forward to your future updates. Just saying thanks will not just be enough, for the extraordinary clarity in your writing. I will immediately grab your rss feed to stay informed of any updates.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dmitry</title>
		<link>http://sitecore.alexiasoft.nl/2008/02/18/benchmarking-highrestimer-and-string-concatenation/comment-page-1/#comment-84375</link>
		<dc:creator>Dmitry</dc:creator>
		<pubDate>Mon, 26 May 2008 14:23:46 +0000</pubDate>
		<guid isPermaLink="false">http://sitecore.alexiasoft.nl/2008/02/18/benchmarking-highrestimer-and-string-concatenation/#comment-84375</guid>
		<description>Hi Alex,

This test is unfair! :) Concatenating just two strings is not a job for StringBuilder at all, and at higher numbers += plainly sucks.

Here are my results: (ms required to perform 1E+6 additions to a string)

Parts: 2
StringBuilder: 109.375
Concat: 109.375
Concat+Array: 140.625
+=: 93.75

Parts: 4
StringBuilder: 250
Concat: 203.125
Concat+Array: 265.625
+=: 250

Parts: 8
StringBuilder: 437.5
Concat: 359.375
Concat+Array: 484.375
+=: 656.25

Parts: 16
StringBuilder: 812.5
Concat: 656.25
Concat+Array: 937.5
+=: 1812.5

Parts: 32
StringBuilder: 1515.625
Concat: 1296.875
Concat+Array: 1843.75
+=: 5187.5

Parts: 64
StringBuilder: 2812.5
Concat: 2515.625
Concat+Array: 3453.125
+=: 16484.375

Parts: 128
StringBuilder: 5359.375
Concat: 4890.625
Concat+Array: 6703.125
+=: 57578.125

You see, already when concatenating 8 strings StringBuilder is better than += it clearly shows O(n) complexity while += shows O(n^2).

string.Concat itself seems wo be the fastest, but... We need to take into account that string.Concat requires an array of strings, and populating an array takes time too. This sole makes Concat + array operations about 10-20% slower than just StringBuilder.

So yeah, happy coding, just make sure your += is not inside a loop ;)

Here is the code I ran to get the results: http://rafb.net/p/0hvZjC71.html

Regards,
Dmitry</description>
		<content:encoded><![CDATA[<p>Hi Alex,</p>
<p>This test is unfair! <img src='http://sitecore.alexiasoft.nl/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  Concatenating just two strings is not a job for StringBuilder at all, and at higher numbers += plainly sucks.</p>
<p>Here are my results: (ms required to perform 1E+6 additions to a string)</p>
<p>Parts: 2<br />
StringBuilder: 109.375<br />
Concat: 109.375<br />
Concat+Array: 140.625<br />
+=: 93.75</p>
<p>Parts: 4<br />
StringBuilder: 250<br />
Concat: 203.125<br />
Concat+Array: 265.625<br />
+=: 250</p>
<p>Parts: 8<br />
StringBuilder: 437.5<br />
Concat: 359.375<br />
Concat+Array: 484.375<br />
+=: 656.25</p>
<p>Parts: 16<br />
StringBuilder: 812.5<br />
Concat: 656.25<br />
Concat+Array: 937.5<br />
+=: 1812.5</p>
<p>Parts: 32<br />
StringBuilder: 1515.625<br />
Concat: 1296.875<br />
Concat+Array: 1843.75<br />
+=: 5187.5</p>
<p>Parts: 64<br />
StringBuilder: 2812.5<br />
Concat: 2515.625<br />
Concat+Array: 3453.125<br />
+=: 16484.375</p>
<p>Parts: 128<br />
StringBuilder: 5359.375<br />
Concat: 4890.625<br />
Concat+Array: 6703.125<br />
+=: 57578.125</p>
<p>You see, already when concatenating 8 strings StringBuilder is better than += it clearly shows O(n) complexity while += shows O(n^2).</p>
<p>string.Concat itself seems wo be the fastest, but&#8230; We need to take into account that string.Concat requires an array of strings, and populating an array takes time too. This sole makes Concat + array operations about 10-20% slower than just StringBuilder.</p>
<p>So yeah, happy coding, just make sure your += is not inside a loop <img src='http://sitecore.alexiasoft.nl/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>Here is the code I ran to get the results: <a href="http://rafb.net/p/0hvZjC71.html" rel="nofollow">http://rafb.net/p/0hvZjC71.html</a></p>
<p>Regards,<br />
Dmitry</p>
]]></content:encoded>
	</item>
</channel>
</rss>

