<?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: C# Object Creation Time Trials</title>
	<atom:link href="http://elegantcode.com/2008/08/21/c-object-creation-time-trials/feed/" rel="self" type="application/rss+xml" />
	<link>http://elegantcode.com/2008/08/21/c-object-creation-time-trials/</link>
	<description></description>
	<lastBuildDate>Fri, 12 Mar 2010 14:11:39 -0600</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Chris Brandsma</title>
		<link>http://elegantcode.com/2008/08/21/c-object-creation-time-trials/comment-page-1/#comment-30084</link>
		<dc:creator>Chris Brandsma</dc:creator>
		<pubDate>Thu, 21 Aug 2008 14:54:08 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2008/08/21/c-object-creation-time-trials/#comment-30084</guid>
		<description>Hi Bjorn,

The object of the tests was not how to eek out every last bit of performance out of .net.  The code was specifically written in normal way to illustrate that .net has good performance without doing strange things.  

Something that I forgot to mention as well was that I ran all the tests in debug mode, not release mode -- which would have helped performance even more.

As for you point about .net is not suitable for real time -- funny, I know a number of guys who did just that with .net in a large manufacturing environment.  I&#039;ll have to tell them their working implementation wont work.  :)</description>
		<content:encoded><![CDATA[<p>Hi Bjorn,</p>
<p>The object of the tests was not how to eek out every last bit of performance out of .net.  The code was specifically written in normal way to illustrate that .net has good performance without doing strange things.  </p>
<p>Something that I forgot to mention as well was that I ran all the tests in debug mode, not release mode &#8212; which would have helped performance even more.</p>
<p>As for you point about .net is not suitable for real time &#8212; funny, I know a number of guys who did just that with .net in a large manufacturing environment.  I&#8217;ll have to tell them their working implementation wont work.  <img src='http://elegantcode.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dew Drop - August 21, 2008 &#124; Alvin Ashcraft's Morning Dew</title>
		<link>http://elegantcode.com/2008/08/21/c-object-creation-time-trials/comment-page-1/#comment-30078</link>
		<dc:creator>Dew Drop - August 21, 2008 &#124; Alvin Ashcraft's Morning Dew</dc:creator>
		<pubDate>Thu, 21 Aug 2008 14:11:14 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2008/08/21/c-object-creation-time-trials/#comment-30078</guid>
		<description>[...] C# Object Creation Time Trials (Chris Brandsma) [...]</description>
		<content:encoded><![CDATA[<p>[...] C# Object Creation Time Trials (Chris Brandsma) [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chris Brandsma</title>
		<link>http://elegantcode.com/2008/08/21/c-object-creation-time-trials/comment-page-1/#comment-30076</link>
		<dc:creator>Chris Brandsma</dc:creator>
		<pubDate>Thu, 21 Aug 2008 13:55:10 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2008/08/21/c-object-creation-time-trials/#comment-30076</guid>
		<description>Hi Nate,

String creation in .net is different than in C in that .net string are immutable and are a managed resource.  

If I do a simple string concatenation:
string a = &quot;abc&quot;;
string b = &quot;def&quot;

a = a b;

In C#, in the a = a b I&#039;m creating a new string that consists of the old a and b.  Also, if I have two string variables with the same text in them, then those variables are actually pointing to the same string.  That is part of being a managed resource.

I put the string concatenation in there to give things a small &quot;real-world&quot; flavor, knowing full well it would slow things down a bit.  After all, to just create 1,000,000 empty objects isn&#039;t saying too much.

But, as a test, I created 1,000,000 strings in 1.6 seconds using the same test.  I did a second test as well where I pre-initialized the collection, thinking this would improve performance -- it did not.  Not noticeably anyway.

As for the time difference between 1000 and 10,000...I can&#039;t completely explain that one.  My thought is that it happens so fast what you are seeing is just the ramp up time for the method.  Or it could be my timing mechanism was not as precise as it is made out to be.</description>
		<content:encoded><![CDATA[<p>Hi Nate,</p>
<p>String creation in .net is different than in C in that .net string are immutable and are a managed resource.  </p>
<p>If I do a simple string concatenation:<br />
string a = &#8220;abc&#8221;;<br />
string b = &#8220;def&#8221;</p>
<p>a = a b;</p>
<p>In C#, in the a = a b I&#8217;m creating a new string that consists of the old a and b.  Also, if I have two string variables with the same text in them, then those variables are actually pointing to the same string.  That is part of being a managed resource.</p>
<p>I put the string concatenation in there to give things a small &#8220;real-world&#8221; flavor, knowing full well it would slow things down a bit.  After all, to just create 1,000,000 empty objects isn&#8217;t saying too much.</p>
<p>But, as a test, I created 1,000,000 strings in 1.6 seconds using the same test.  I did a second test as well where I pre-initialized the collection, thinking this would improve performance &#8212; it did not.  Not noticeably anyway.</p>
<p>As for the time difference between 1000 and 10,000&#8230;I can&#8217;t completely explain that one.  My thought is that it happens so fast what you are seeing is just the ramp up time for the method.  Or it could be my timing mechanism was not as precise as it is made out to be.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bjorn Reppen</title>
		<link>http://elegantcode.com/2008/08/21/c-object-creation-time-trials/comment-page-1/#comment-30074</link>
		<dc:creator>Bjorn Reppen</dc:creator>
		<pubDate>Thu, 21 Aug 2008 13:48:16 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2008/08/21/c-object-creation-time-trials/#comment-30074</guid>
		<description>&gt;1. that C   is the most efficient language out there
&gt;My answer to #1 is: that depends on the developer 

You are right.  The constructor on list has an overload which could have saved you all the &quot;array&quot; copying that goes on in the background.  This would also help you avoid the exponential time curve.

&gt;2. That .net is too inefficient to do any real work

If real work means web server to handle thousands of simultaneous requests with immediate responses, you have probably just proved above that .net is too slow to do any &#039;real&#039; work.  .Net is also often unsuited for real-time apps.

Also keep in mind when testing that the GC will only kick in after you have been running for a while - performance will drop even more at that point. (run longer tests)</description>
		<content:encoded><![CDATA[<p>&gt;1. that C   is the most efficient language out there<br />
&gt;My answer to #1 is: that depends on the developer </p>
<p>You are right.  The constructor on list has an overload which could have saved you all the &#8220;array&#8221; copying that goes on in the background.  This would also help you avoid the exponential time curve.</p>
<p>&gt;2. That .net is too inefficient to do any real work</p>
<p>If real work means web server to handle thousands of simultaneous requests with immediate responses, you have probably just proved above that .net is too slow to do any &#8216;real&#8217; work.  .Net is also often unsuited for real-time apps.</p>
<p>Also keep in mind when testing that the GC will only kick in after you have been running for a while &#8211; performance will drop even more at that point. (run longer tests)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nate</title>
		<link>http://elegantcode.com/2008/08/21/c-object-creation-time-trials/comment-page-1/#comment-30069</link>
		<dc:creator>Nate</dc:creator>
		<pubDate>Thu, 21 Aug 2008 13:13:23 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2008/08/21/c-object-creation-time-trials/#comment-30069</guid>
		<description>First,  is it possible that string creation is the problem between the 500k and the 1M?  I&#039;ve worked on C   projects where more string creation caused exponential load time. What I mean, is, does .Net new up strings in a different enough way that it could cause exponential problems?

Second, based on your results, I&#039;ve decided that if I&#039;m going to create 1000 objects, I might as well create 10,000.  After all, 10,000 is 10x better than 1000 and I get it for the same cost :)</description>
		<content:encoded><![CDATA[<p>First,  is it possible that string creation is the problem between the 500k and the 1M?  I&#8217;ve worked on C   projects where more string creation caused exponential load time. What I mean, is, does .Net new up strings in a different enough way that it could cause exponential problems?</p>
<p>Second, based on your results, I&#8217;ve decided that if I&#8217;m going to create 1000 objects, I might as well create 10,000.  After all, 10,000 is 10x better than 1000 and I get it for the same cost <img src='http://elegantcode.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
</channel>
</rss>
