<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Deserialized</title>
	<atom:link href="http://deserialized.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://deserialized.com</link>
	<description>Just another WordPress weblog</description>
	<lastBuildDate>Mon, 12 Jul 2010 17:13:19 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>ObjectID&#8217;s with MongoDB and the mongodb-csharp driver</title>
		<link>http://deserialized.com/objectids-with-mongodb-and-the-mongodb-csharp-driver/</link>
		<comments>http://deserialized.com/objectids-with-mongodb-and-the-mongodb-csharp-driver/#comments</comments>
		<pubDate>Mon, 12 Jul 2010 17:06:38 +0000</pubDate>
		<dc:creator>Bryan Migliorisi</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Gotcha]]></category>
		<category><![CDATA[mongodb]]></category>
		<category><![CDATA[csharp]]></category>
		<category><![CDATA[web development]]></category>

		<guid isPermaLink="false">http://deserialized.com/objectids-with-mongodb-and-the-mongodb-csharp-driver/</guid>
		<description><![CDATA[I mist say, the latest release of mongodb-csharp is rather awesome.&#160; Typed collections and LINQ support mean I can worry more about my application than about the data layer. Here is an example of using typed collections: public class Customer { public Oid Id { get; set; } public string Name { get; set; } [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fdeserialized.com%2Fobjectids-with-mongodb-and-the-mongodb-csharp-driver%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fdeserialized.com%2Fobjectids-with-mongodb-and-the-mongodb-csharp-driver%2F&amp;source=BryanMigliorisi&amp;style=normal&amp;service=is.gd" height="61" width="50" /><br />
			</a>
		</div>
<p>I mist say, the latest release of <a title="MongoDB C# Driver" href="http://github.com/samus/mongodb-csharp">mongodb-csharp</a> is rather awesome.&#160; Typed collections and LINQ support mean I can worry more about my application than about the data layer.</p>
<p>Here is an example of using typed collections:</p>
<pre class="csharp">public class Customer
{
	public Oid Id { get; set; }
	public string Name { get; set; }
	public CustomerBillingInfo Billing { get; set; }
	public List<customerdepartment> Depts { get; set; }
}

public void AddCustomer(Customer customer) {
	...(code removed for simplicity)...
	IMongoCollection&lt;customer&gt; collection = database.GetCollection&lt;customer&gt;();
	collection.Save(customer);
}</pre>
<h2>Gotcha: Beware of the ID property!</h2>
<p>One thing that threw me off when I began using the typed collections was that I had defined my ID property as “<font face="Courier New">_id</font>” because That is what <a title="MongoDB" href="http://www.mongodb.org/">MongoDB</a> uses internally.&#160; While this made sense to me, the <font face="Courier New">mongod</font> process kept throwing errors whenever I tried the following:</p>
<pre class="csharp">...(code removed for simplicity)...
IMongoCollection&lt;customer&gt; collection = database.GetCollection&lt;customer&gt;();
Customer customer = collection.Linq().First(c =&gt; c.Name == &quot;test customer&quot;);
customer.Name = &quot;A new name!&quot;;
collection.Save(customer);</pre>
<p>The error looked something like this:</p>
<pre>Fri Jun 25 10:43:14 Exception 11000:E11000 duplicate key error index: test06.Customer.$_id_  dup key: { : ObjId(4c24c07a189cf31bd4000002) }
Fri Jun 25 10:43:14    Caught Assertion in insert , continuing
Fri Jun 25 10:43:14 insert test06.Customer exception userassert:E11000 duplicate key error index: test06.Customer.$_id_  dup key: { : ObjId(4c24c07a189cf31bd4000002) } 21ms</pre>
<p>It was driving me crazy for days before I realized that the driver was doing some magic – the POCO object needed its ID to be named “Id” instead of “_id” an as soon as I changed that – it started working properly.</p>
<p>
				<table cellspacing="0" cellpadding="0" border="0" style="width: 300px; height: 50px; text-align: left; margin-left: auto; margin-right: auto;">
				<tbody>
				<tr>
				<td style="text-align: center;">
				<a href="http://del.icio.us/post?url=http://deserialized.com/objectids-with-mongodb-and-the-mongodb-csharp-driver/&title=ObjectID&rsquo;s with MongoDB and the mongodb-csharp driver" rel="nofollow">
				<img src="http://deserialized.com/wp-content/plugins/addtothis/delicious.png" alt="Add to Del.cio.us" style="border: 0px solid ; width: 48px; height: 48px;"/>
				</a>
				</td>
				<td style="text-align: center;">
				<a href="http://deserialized.com/feed/rss/" rel="nofollow">
				<img src="http://deserialized.com/wp-content/plugins/addtothis/feeds.png" alt="RSS Feed" style="border: 0px solid ; width: 48px; height: 48px;"/>
				</a>
				</td>
				<td style="text-align: center;">
				<a href="http://technorati.com/faves?add=http://deserialized.com/objectids-with-mongodb-and-the-mongodb-csharp-driver/" rel="nofollow">
				<img src="http://deserialized.com/wp-content/plugins/addtothis/technorati.png" alt="Add to Technorati Favorites" style="border: 0px solid ; width: 48px; height: 48px;"/>
				</a>
				</td>
				<td style="text-align: center;">
				<a href="http://www.stumbleupon.com/submit?url=http://deserialized.com/objectids-with-mongodb-and-the-mongodb-csharp-driver/&title=ObjectID&rsquo;s with MongoDB and the mongodb-csharp driver" rel="nofollow">
				<img src="http://deserialized.com/wp-content/plugins/addtothis/stumble.png" alt="Stumble It!" style="border: 0px solid ; width: 48px; height: 48px;"/>
				</a>
				
				</td>
				<td style="text-align: center;">
				<a href="http://digg.com/submit?phase=2&url=http://deserialized.com/objectids-with-mongodb-and-the-mongodb-csharp-driver/" rel="nofollow">
				<img src="http://deserialized.com/wp-content/plugins/addtothis/digg.png" alt="Digg It!" style="border: 0px solid ; width: 48px; height: 48px;"/>
				</a>
				
				</td>
				</tr>
				<tr><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td style="text-align: right;" ><a href="http://www.sajithmr.com"><img style="border:none" src="http://deserialized.com/wp-content/plugins/addtothis/sajithmr.png"  title="Powered By Sajithmr.com" alt="www.sajithmr.com"/></a></td></tr>
				</tbody>
				</table>

                
		
				</p>]]></content:encoded>
			<wfw:commentRss>http://deserialized.com/objectids-with-mongodb-and-the-mongodb-csharp-driver/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Convert C# classes to and from MongoDB Documents automatically using .NET reflection</title>
		<link>http://deserialized.com/convert-csharp-classes-to-and-from-mongodb-documents-automatically-using-net-reflection/</link>
		<comments>http://deserialized.com/convert-csharp-classes-to-and-from-mongodb-documents-automatically-using-net-reflection/#comments</comments>
		<pubDate>Thu, 25 Feb 2010 15:47:23 +0000</pubDate>
		<dc:creator>Bryan Migliorisi</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[mongodb]]></category>
		<category><![CDATA[csharp]]></category>
		<category><![CDATA[dotnet]]></category>
		<category><![CDATA[mongo]]></category>

		<guid isPermaLink="false">http://deserialized.com/?p=53</guid>
		<description><![CDATA[There are a number of C# based MongoDB projects being actively developed right now but one thing that I needed was a way to convert a standard C# class to a MongoDB document for easy insertion.&#160; It isn&#8217;t hard to manually type out and set each property by hand, but it certainly is not the [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fdeserialized.com%2Fconvert-csharp-classes-to-and-from-mongodb-documents-automatically-using-net-reflection%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fdeserialized.com%2Fconvert-csharp-classes-to-and-from-mongodb-documents-automatically-using-net-reflection%2F&amp;source=BryanMigliorisi&amp;style=normal&amp;service=is.gd" height="61" width="50" /><br />
			</a>
		</div>
<p>There are a <a href="http://deserialized.com/the-state-of-mongodb-and-csharp/">number of C# based MongoDB projects</a> being actively developed right now but one thing that I needed was a way to convert a standard C# class to a <a href="http://www.mongodb.com">MongoDB</a> document for easy insertion.&#160; It isn&#8217;t hard to manually type out and set each property by hand, but it certainly is not the most efficient way, especially when you know you are going to be doing it a lot.</p>
<p>&#160;</p>
<p>For example:</p>
<p>Lets say I have a class called <em>SomeClass</em> that looks something like this:</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #FF0000;">class</span> SomeClass <span style="color: #000000;">&#123;</span>
	<span style="color: #0600FF;">public</span> <span style="color: #FF0000;">string</span> StringTest<span style="color: #008000;">;</span>
	<span style="color: #0600FF;">public</span> <span style="color: #FF0000;">int</span> IntTest<span style="color: #008000;">;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

<p>And somewhere in my code, I have an instance of this class named <em>someClassInstance</em>.&#160; If I want to create a MongoDB document from this class, I’d have to do something like this:</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;">Document document <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> Document<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
document.<span style="color: #0000FF;">add</span><span style="color: #000000;">&#40;</span><span style="color: #666666;">'StringTest'</span>, someClassInstance.<span style="color: #0000FF;">StringTest</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
document.<span style="color: #0000FF;">add</span><span style="color: #000000;">&#40;</span><span style="color: #666666;">'IntTest'</span>, someClassInstance.<span style="color: #0000FF;">IntTest</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span></pre></div></div>

<p>So that isn&#8217;t such a big deal, right? But what about when I have a class with many more properties?&#160; Then it starts to get messy and cumbersome.&#160; I thought that there should be an straightforward way to easily convert any class to a mongo-csharp compatible Document object. (I am using <a href="http://twitter.com/samcorder">Sam Corder’s</a> <a href="http://github.com/samus/mongodb-csharp">mongo-csharp driver</a>, so that I am targeting the Document object from that library.)</p>
<p>&#160;</p>
<h3>Default values</h3>
<p>I also wanted to have a way to specify what the default values were for each class property so that when we did the conversion, we would (hopefully) not end up with any null values.&#160; Plus, if for some reason there was a document in MongoDB that was missing a particular key-value pair, the DocumentConverter would automatically fill in that empty field with the default value so in the code we should never have any nulls.</p>
<p>This is something that I would like for my own purposes and may not suit everyone’s needs.&#160; If it doesn&#8217;t, simply leave off the DefaultValueAttribute and you’ll never know the difference.</p>
<h3></h3>
<p>&#160;</p>
<h3>My proposed solution</h3>
<p>I figured the easiest way to accomplish this was to create a class that would encapsulate all the functionality needed to convert to and from Document objects and have my other classes inherit from that one. I imagined that the above code would change to something like this:</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #FF0000;">class</span> SomeClass <span style="color: #008000;">:</span> DocumentConverter <span style="color: #000000;">&#123;</span>
	<span style="color: #000000;">&#91;</span>Attributes.<span style="color: #0000FF;">DefaultValue</span><span style="color: #000000;">&#40;</span><span style="color: #008000;">&amp;</span>quot<span style="color: #008000;">;</span>Default StringTest value<span style="color: #008000;">!&amp;</span>quot<span style="color: #008000;">;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#93;</span>
	<span style="color: #0600FF;">public</span> <span style="color: #FF0000;">string</span> StringTest<span style="color: #008000;">;</span>
	<span style="color: #000000;">&#91;</span>Attributes.<span style="color: #0000FF;">DefaultValue</span><span style="color: #000000;">&#40;</span><span style="color: #FF0000;">16</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#93;</span>
	<span style="color: #0600FF;">public</span> <span style="color: #FF0000;">int</span> IntTest<span style="color: #008000;">;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

<p>And to do the conversion would be very simple.&#160; To convert from <em>someClass</em> to <em>Document</em> would be:</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;">Document document <span style="color: #008000;">=</span> someClassInstance.<span style="color: #0000FF;">ToMongoDocument</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span></pre></div></div>

<p>To convert from a <em>Document</em> object to <em>someClass</em> would be:</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;">SomeClass someOtherClassInstance <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> SomeClass<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
omeOtherClassInstance .<span style="color: #0000FF;">FromMongoDocument</span><span style="color: #000000;">&#40;</span>someDocumentObject<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span></pre></div></div>

<p>&#160;</p>
<h3>The DefaultAttribute class</h3>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF;">using</span> <span style="color: #008080;">System</span><span style="color: #008000;">;</span></pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF;">namespace</span> MyApp.<span style="color: #0000FF;">Attributes</span>
<span style="color: #000000;">&#123;</span>
    <span style="color: #000000;">&#91;</span>AttributeUsage<span style="color: #000000;">&#40;</span>AttributeTargets.<span style="color: #0000FF;">Field</span> <span style="color: #008000;">|</span> AttributeTargets.<span style="color: #0000FF;">Property</span>, AllowMultiple <span style="color: #008000;">=</span> <span style="color: #0600FF;">false</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#93;</span>
    <span style="color: #FF0000;">class</span> DefaultValueAttribute <span style="color: #008000;">:</span> Attribute
    <span style="color: #000000;">&#123;</span>
        <span style="color: #0600FF;">private</span> <span style="color: #0600FF;">readonly</span> <span style="color: #FF0000;">object</span> _value<span style="color: #008000;">;</span>
&nbsp;
        <span style="color: #0600FF;">public</span> DefaultValueAttribute<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">object</span> Value<span style="color: #000000;">&#41;</span>
        <span style="color: #000000;">&#123;</span>
            _value <span style="color: #008000;">=</span> Value<span style="color: #008000;">;</span>
        <span style="color: #000000;">&#125;</span>
&nbsp;
        <span style="color: #0600FF;">public</span> <span style="color: #FF0000;">object</span> GetDefaultValue<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
        <span style="color: #000000;">&#123;</span>
            <span style="color: #0600FF;">return</span> _value<span style="color: #008000;">;</span>
        <span style="color: #000000;">&#125;</span>
    <span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

<h3>The DocumentConverter class</h3>
<p>Reflection isn&#8217;t something that I use too often so there may be better ways of accomplishing what I am trying to do, but this is what I’ve got for now.&#160; If there are better ways, please let me know.&#160; Without further ado…</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF;">using</span> <span style="color: #008080;">System</span><span style="color: #008000;">;</span>
<span style="color: #0600FF;">using</span> <span style="color: #008080;">System.Collections</span><span style="color: #008000;">;</span>
<span style="color: #0600FF;">using</span> <span style="color: #008080;">System.Collections.Generic</span><span style="color: #008000;">;</span>
<span style="color: #0600FF;">using</span> <span style="color: #008080;">System.Linq</span><span style="color: #008000;">;</span>
<span style="color: #0600FF;">using</span> <span style="color: #008080;">System.Reflection</span><span style="color: #008000;">;</span>
<span style="color: #0600FF;">using</span> <span style="color: #008080;">System.Text</span><span style="color: #008000;">;</span>
<span style="color: #0600FF;">using</span> <span style="color: #008080;">MyApp.Classes.Attributes</span><span style="color: #008000;">;</span>
<span style="color: #0600FF;">using</span> <span style="color: #008080;">MongoDB.Driver</span><span style="color: #008000;">;</span>
&nbsp;
<span style="color: #0600FF;">namespace</span> MyApp.<span style="color: #0000FF;">Classes</span>
<span style="color: #000000;">&#123;</span>
    <span style="color: #0600FF;">public</span> <span style="color: #FF0000;">class</span> DocumentConverter
    <span style="color: #000000;">&#123;</span>
        <span style="color: #0600FF;">public</span> <span style="color: #0600FF;">void</span> FromMongoDocument<span style="color: #000000;">&#40;</span>Document document<span style="color: #000000;">&#41;</span>
        <span style="color: #000000;">&#123;</span>
            <span style="color: #0600FF;">foreach</span> <span style="color: #000000;">&#40;</span>DictionaryEntry kvp <span style="color: #0600FF;">in</span> document<span style="color: #000000;">&#41;</span>
            <span style="color: #000000;">&#123;</span>
                <span style="color: #FF0000;">object</span> propertyValue<span style="color: #008000;">;</span>
                <span style="color: #0600FF;">if</span> <span style="color: #000000;">&#40;</span>kvp.<span style="color: #0000FF;">Value</span> <span style="color: #008000;">!=</span> <span style="color: #0600FF;">null</span> <span style="color: #008000;">&amp;</span>amp<span style="color: #008000;">;&amp;</span>amp<span style="color: #008000;">;</span> <span style="color: #000000;">&#40;</span>kvp.<span style="color: #0000FF;">Value</span>.<span style="color: #0000FF;">GetType</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #008000;">==</span> <span style="color: #008000;">typeof</span><span style="color: #000000;">&#40;</span>Document<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>
                <span style="color: #000000;">&#123;</span>
                    <span style="color: #008080; font-style: italic;">// We have a document object - Now lets get a reference to the class property's type</span>
                    var propertyType <span style="color: #008000;">=</span> GetType<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>.<span style="color: #0000FF;">GetProperty</span><span style="color: #000000;">&#40;</span>kvp.<span style="color: #0000FF;">Key</span>.<span style="color: #0000FF;">ToString</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>.<span style="color: #0000FF;">PropertyType</span><span style="color: #008000;">;</span>
&nbsp;
                    <span style="color: #008080; font-style: italic;">// create new instance of that class</span>
                    var propertyInstance <span style="color: #008000;">=</span> Activator.<span style="color: #0000FF;">CreateInstance</span><span style="color: #000000;">&#40;</span>propertyType<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
                    <span style="color: #008080; font-style: italic;">// call FromMongoDocument on that class and pass in the document</span>
                    MethodInfo method <span style="color: #008000;">=</span> propertyInstance.<span style="color: #0000FF;">GetType</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>.<span style="color: #0000FF;">GetMethod</span><span style="color: #000000;">&#40;</span><span style="color: #008000;">&amp;</span>quot<span style="color: #008000;">;</span>FromMongoDocument<span style="color: #008000;">&amp;</span>quot<span style="color: #008000;">;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
                    method.<span style="color: #0000FF;">Invoke</span><span style="color: #000000;">&#40;</span>propertyInstance, <span style="color: #008000;">new</span><span style="color: #000000;">&#91;</span><span style="color: #000000;">&#93;</span> <span style="color: #000000;">&#123;</span> kvp.<span style="color: #0000FF;">Value</span> <span style="color: #000000;">&#125;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
                    propertyValue <span style="color: #008000;">=</span> propertyInstance<span style="color: #008000;">;</span>
                <span style="color: #000000;">&#125;</span>
                <span style="color: #0600FF;">else</span>
                <span style="color: #000000;">&#123;</span>
                    <span style="color: #008080; font-style: italic;">// This is not a Document so lets just assign the value</span>
                    propertyValue <span style="color: #008000;">=</span> kvp.<span style="color: #0000FF;">Value</span><span style="color: #008000;">;</span>
                <span style="color: #000000;">&#125;</span>
&nbsp;
                GetType<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>.<span style="color: #0000FF;">GetProperty</span><span style="color: #000000;">&#40;</span>kvp.<span style="color: #0000FF;">Key</span>.<span style="color: #0000FF;">ToString</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>.<span style="color: #0000FF;">SetValue</span><span style="color: #000000;">&#40;</span><span style="color: #0600FF;">this</span>, propertyValue, <span style="color: #0600FF;">null</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
            <span style="color: #000000;">&#125;</span>
&nbsp;
        <span style="color: #000000;">&#125;</span>
&nbsp;
        <span style="color: #0600FF;">public</span> Document ToMongoDocument<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
        <span style="color: #000000;">&#123;</span>
            Document document <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> Document<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
            <span style="color: #0600FF;">foreach</span> <span style="color: #000000;">&#40;</span>PropertyInfo property <span style="color: #0600FF;">in</span> GetType<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>.<span style="color: #0000FF;">GetProperties</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>
            <span style="color: #000000;">&#123;</span>
                <span style="color: #008080; font-style: italic;">// Get the value of this property</span>
                <span style="color: #FF0000;">object</span> propertyValue <span style="color: #008000;">=</span> property.<span style="color: #0000FF;">GetValue</span><span style="color: #000000;">&#40;</span><span style="color: #0600FF;">this</span>, <span style="color: #0600FF;">null</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
                <span style="color: #008080; font-style: italic;">// If this value is null, then lets try to see if there is a default value attribute and assign that</span>
                <span style="color: #0600FF;">if</span> <span style="color: #000000;">&#40;</span>propertyValue <span style="color: #008000;">==</span> <span style="color: #0600FF;">null</span><span style="color: #000000;">&#41;</span>
                <span style="color: #000000;">&#123;</span>
                    <span style="color: #FF0000;">object</span><span style="color: #000000;">&#91;</span><span style="color: #000000;">&#93;</span> attributes <span style="color: #008000;">=</span> property.<span style="color: #0000FF;">GetCustomAttributes</span><span style="color: #000000;">&#40;</span><span style="color: #008000;">typeof</span><span style="color: #000000;">&#40;</span>DefaultValueAttribute<span style="color: #000000;">&#41;</span>, <span style="color: #0600FF;">true</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
                    <span style="color: #0600FF;">foreach</span> <span style="color: #000000;">&#40;</span>DefaultValueAttribute defaultValue <span style="color: #0600FF;">in</span> attributes.<span style="color: #0000FF;">Cast</span><span style="color: #008000;">&lt;</span>defaultvalueattribute<span style="color: #008000;">&gt;</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>
                    <span style="color: #000000;">&#123;</span>
                        propertyValue <span style="color: #008000;">=</span> defaultValue.<span style="color: #0000FF;">GetDefaultValue</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
                    <span style="color: #000000;">&#125;</span>
                    document.<span style="color: #0000FF;">Add</span><span style="color: #000000;">&#40;</span>property.<span style="color: #0000FF;">Name</span>, propertyValue<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
                <span style="color: #000000;">&#125;</span>
                <span style="color: #0600FF;">else</span>
                <span style="color: #000000;">&#123;</span>
                    <span style="color: #008080; font-style: italic;">// We have a property, now lets see if this property has a ToMongoDocument method</span>
                    MethodInfo method <span style="color: #008000;">=</span> propertyValue.<span style="color: #0000FF;">GetType</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>.<span style="color: #0000FF;">GetMethod</span><span style="color: #000000;">&#40;</span><span style="color: #008000;">&amp;</span>quot<span style="color: #008000;">;</span>ToMongoDocument<span style="color: #008000;">&amp;</span>quot<span style="color: #008000;">;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
                    <span style="color: #0600FF;">if</span> <span style="color: #000000;">&#40;</span>method <span style="color: #008000;">==</span> <span style="color: #0600FF;">null</span><span style="color: #000000;">&#41;</span>
                    <span style="color: #000000;">&#123;</span>
                        document.<span style="color: #0000FF;">Add</span><span style="color: #000000;">&#40;</span>property.<span style="color: #0000FF;">Name</span>, property.<span style="color: #0000FF;">GetValue</span><span style="color: #000000;">&#40;</span><span style="color: #0600FF;">this</span>, <span style="color: #0600FF;">null</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
                    <span style="color: #000000;">&#125;</span>
                    <span style="color: #0600FF;">else</span>
                    <span style="color: #000000;">&#123;</span>
                        document.<span style="color: #0000FF;">Add</span><span style="color: #000000;">&#40;</span>property.<span style="color: #0000FF;">Name</span>, method.<span style="color: #0000FF;">Invoke</span><span style="color: #000000;">&#40;</span>propertyValue, <span style="color: #0600FF;">null</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
                    <span style="color: #000000;">&#125;</span>
                <span style="color: #000000;">&#125;</span>
            <span style="color: #000000;">&#125;</span>
            <span style="color: #0600FF;">return</span> document<span style="color: #008000;">;</span>
        <span style="color: #000000;">&#125;</span>
    <span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

<h3>That’s all for now</h3>
<p>I hope this is useful for someone.&#160; It is a rough draft of what I threw together last night at around 1AM while half asleep.&#160; So far, it has passed all of my initial tests but if you have suggestions to make it better, please leave some comments here. </p>
<p>
				<table cellspacing="0" cellpadding="0" border="0" style="width: 300px; height: 50px; text-align: left; margin-left: auto; margin-right: auto;">
				<tbody>
				<tr>
				<td style="text-align: center;">
				<a href="http://del.icio.us/post?url=http://deserialized.com/convert-csharp-classes-to-and-from-mongodb-documents-automatically-using-net-reflection/&title=Convert C# classes to and from MongoDB Documents automatically using .NET reflection" rel="nofollow">
				<img src="http://deserialized.com/wp-content/plugins/addtothis/delicious.png" alt="Add to Del.cio.us" style="border: 0px solid ; width: 48px; height: 48px;"/>
				</a>
				</td>
				<td style="text-align: center;">
				<a href="http://deserialized.com/feed/rss/" rel="nofollow">
				<img src="http://deserialized.com/wp-content/plugins/addtothis/feeds.png" alt="RSS Feed" style="border: 0px solid ; width: 48px; height: 48px;"/>
				</a>
				</td>
				<td style="text-align: center;">
				<a href="http://technorati.com/faves?add=http://deserialized.com/convert-csharp-classes-to-and-from-mongodb-documents-automatically-using-net-reflection/" rel="nofollow">
				<img src="http://deserialized.com/wp-content/plugins/addtothis/technorati.png" alt="Add to Technorati Favorites" style="border: 0px solid ; width: 48px; height: 48px;"/>
				</a>
				</td>
				<td style="text-align: center;">
				<a href="http://www.stumbleupon.com/submit?url=http://deserialized.com/convert-csharp-classes-to-and-from-mongodb-documents-automatically-using-net-reflection/&title=Convert C# classes to and from MongoDB Documents automatically using .NET reflection" rel="nofollow">
				<img src="http://deserialized.com/wp-content/plugins/addtothis/stumble.png" alt="Stumble It!" style="border: 0px solid ; width: 48px; height: 48px;"/>
				</a>
				
				</td>
				<td style="text-align: center;">
				<a href="http://digg.com/submit?phase=2&url=http://deserialized.com/convert-csharp-classes-to-and-from-mongodb-documents-automatically-using-net-reflection/" rel="nofollow">
				<img src="http://deserialized.com/wp-content/plugins/addtothis/digg.png" alt="Digg It!" style="border: 0px solid ; width: 48px; height: 48px;"/>
				</a>
				
				</td>
				</tr>
				<tr><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td style="text-align: right;" ><a href="http://www.sajithmr.com"><img style="border:none" src="http://deserialized.com/wp-content/plugins/addtothis/sajithmr.png"  title="Powered By Sajithmr.com" alt="www.sajithmr.com"/></a></td></tr>
				</tbody>
				</table>

                
		
				</p>]]></content:encoded>
			<wfw:commentRss>http://deserialized.com/convert-csharp-classes-to-and-from-mongodb-documents-automatically-using-net-reflection/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>The Current State of MongoDB and C#</title>
		<link>http://deserialized.com/the-state-of-mongodb-and-csharp/</link>
		<comments>http://deserialized.com/the-state-of-mongodb-and-csharp/#comments</comments>
		<pubDate>Tue, 23 Feb 2010 19:24:03 +0000</pubDate>
		<dc:creator>Bryan Migliorisi</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[mongodb]]></category>
		<category><![CDATA[csharp]]></category>
		<category><![CDATA[mongo]]></category>
		<category><![CDATA[nosql]]></category>

		<guid isPermaLink="false">http://deserialized.com/the-state-of-mondodb-and-csharp/</guid>
		<description><![CDATA[As a C# developer, I am often disappointed with the lack of drivers and connectors to cool services like MongoDB.  All the cool languages (and Java) get all the love but C# is often an afterthought. Luckily for me, there are some kickass developers in the C# community who also share my frustration and as [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fdeserialized.com%2Fthe-state-of-mongodb-and-csharp%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fdeserialized.com%2Fthe-state-of-mongodb-and-csharp%2F&amp;source=BryanMigliorisi&amp;style=normal&amp;service=is.gd" height="61" width="50" /><br />
			</a>
		</div>
<p>As a C# developer, I am often disappointed with the lack of drivers and connectors to cool services like <a href="http://www.mongodb.org/display/DOCS/Home">MongoDB</a>.  All the cool languages (and Java) get all the love but C# is often an afterthought.</p>
<p>Luckily for me, there are some kickass developers in the C# community who also share my frustration and as such, they have begun building their own C# <a href="http://www.mongodb.org/display/DOCS/Home">MongoDB</a> drivers.</p>
<p>I keep stumbling across more and more C# related <a href="http://www.mongodb.org/display/DOCS/Home">MongoDB</a> projects, so I figured I would write up a list and some short descriptions of these projects.</p>
<p><strong> </strong></p>
<h2>List of C# <a href="http://www.mongodb.org/display/DOCS/Home">MongoDB</a> Projects</h2>
<p>Each of these projects are still rather new, so expect some features to be missing or not fully functional.  A couple of them are usable in your projects today while the rest are still under heavy development</p>
<h3><strong><a href="http://github.com/samus/mongodb-csharp">mongodb-csharp</a></strong></h3>
<p>Originally written by Sam Corder (<a href="http://twitter.com/samcorder">@SamCorder</a>) with help from a handful of contributers, this is the most complete driver of the bunch. It has been evolving quickly and Sam &amp; team are very quick to resolve any bugs that may arise.</p>
<p>I am using this driver in 2 projects that I am working on and so far things have been great.  It even includes GridFS suport.</p>
<p>From the project description:</p>
<h4>Current Features</h4>
<ul>
<li>Connect to a server.</li>
<li>Query</li>
<li>Insert</li>
<li>Update</li>
<li>Delete</li>
<li>All BSON types supported</li>
<li>DBRef support</li>
<li>Isolation and conversion between BSON types and native .net types.</li>
<li>Database, Collection and Cursor objects.</li>
<li>Index handling routines (List, Create, Drop)</li>
<li>Count</li>
<li>Roughly 80% unit test coverage. This can and will be improved on.</li>
<li>Paired connections</li>
<li>Authentication (Does not reauthorize on auto reconnect yet).</li>
<li>Database Commands</li>
<li>Basic Linq support</li>
<li>GridFS support</li>
<li>Map Reduce helpers.</li>
<li>hint, explain, $where</li>
</ul>
<p>They are currently working on connection management features (auto reconnect, connection pooling, etc).</p>
<p>Get involved or check out the code at their <a href="http://github.com/samus/mongodb-csharp">mongodb-csharp project page on Github</a>.</p>
<h3></h3>
<h3>mongodb-net</h3>
<p>Written by the unnamed developer at <a href="http://www.devfuel.com/">DevFuel.com</a>, the mongo-net project aims to be a C# port of the 10Gen\MongoDB official Java driver.  While a lot of work has been done and a load of code written, it is currently unusable.  Over the past couple of weeks a significant amount of progress has been made and functionality is beginning to work but it seems that a functional state is months away.</p>
<p>I would keep an eye on this project, though, as having an API compatible with the official Java driver has its benefits.</p>
<p>Get involved or check out the code at their <a href="http://code.google.com/p/mongodb-net/">mongodb-net project page on Google Code</a>.</p>
<p><strong> </strong></p>
<h3>MongoDB.Emitter</h3>
<p>Andrew Rondeau’s <a href="http://groups.google.com/group/mongodb-user/browse_thread/thread/d85b91a68145bee3">MongoDB.Emitter</a> is a pretty cool project that provides a strongly-typed Document mapper for C#.  It works in conjunction with Sam Corder’s mongodb-csharp driver allowing the programmer to define strongly typed interfaces and properties.</p>
<p>I have not tried this yet, but this will be on my list of things to check out.</p>
<p>Get involved or check out the code at their <a href="http://bitbucket.org/gwbasic/mongodb.emitter/">MongoDB.Emitter project page on bitbucket</a>.</p>
<h3>CSMongo</h3>
<p>Hugo Bonacci (<a href="http://twitter.com/hugoware">@hugoware</a>) has been working on a driver of his own called CSMongo. CSMongo doesnt support everything that mongodb-csharp does but it does have some interesting features, such as the approach to creating Mongo Documents.  Their approach definitely has a more dynamic feel to it which fites nicely in the unstructured MongoDB world.</p>
<p>I am looking forward to the next version which should have more features including support for Hugo’s own <a href="http://www.hugoware.net/projects/jlinq">jLinq</a>.</p>
<p>Code doesn&#8217;t appear to be released yet but you can follow his progress at his blog, <a href="http://somewebguy.wordpress.com/2010/02/21/building-a-mongo-driver-part-1/">Hugoware</a>.</p>
<h3>simple-mongodb</h3>
<p>Simple-mongdb is another project without public source that is being worked on by Daniel Wertheim (<a href="http://twitter.com/danielwertheim">@danielwertheim</a>).  I am not sure if it is even being actively developed but it too has some nice ideas.  The goal of this project is to keep the driver JSON-centric and should be compatible with awesome Newtonsoft’s JSON.net library.</p>
<p>They have a few examples of the proposed API but no code has been released to make said examples work.  This is another one to keep an eye on in the meantime.</p>
<p>Check out the <a href="http://code.google.com/p/simple-mongodb/">simple-mongodb project page on Google Code</a>.</p>
<h3>DocumentConverter</h3>
<p>This is a small class I wrote that works with mongodb-csharp.  Its name will likely change at some point if and when it gets packaged up and put on source control.  It exposes two functions that will allow any C# class to convert to and from a MongoDB Document object automatically.  It makes my life a lot easier and it uses System.Reflection to do this.</p>
<p>Read more about <a href="http://deserialized.com/convert-csharp-classes-to-and-from-mongodb-documents-automatically-using-net-reflection">DocumentConverter on this blog post.</a></p>
<h2>Conclusion</h2>
<p>Well it looks like there is a significant amount of interest in MongoDB from the C# community which is great news because it looks like MongoDB is going to continue to thrive and grow.  My bet is that Sam Corder’s driver will be the most common C# driver, simply because it is so far ahead of the rest but time will tell.  Extensions of Sam’s project, such as MongoDB.Emitter, are equally as cool as the drivers they are built on.</p>
<p>Thanks toeveryone who has contributed to these drivers.  Each of them have some great concepts and I hope that one day we will have a driver that supports all these great ideas and features.</p>
<p><strong>If there are any more projects that I have missed – let me know in the comments!</strong></p>
<p>
				<table cellspacing="0" cellpadding="0" border="0" style="width: 300px; height: 50px; text-align: left; margin-left: auto; margin-right: auto;">
				<tbody>
				<tr>
				<td style="text-align: center;">
				<a href="http://del.icio.us/post?url=http://deserialized.com/the-state-of-mongodb-and-csharp/&title=The Current State of MongoDB and C#" rel="nofollow">
				<img src="http://deserialized.com/wp-content/plugins/addtothis/delicious.png" alt="Add to Del.cio.us" style="border: 0px solid ; width: 48px; height: 48px;"/>
				</a>
				</td>
				<td style="text-align: center;">
				<a href="http://deserialized.com/feed/rss/" rel="nofollow">
				<img src="http://deserialized.com/wp-content/plugins/addtothis/feeds.png" alt="RSS Feed" style="border: 0px solid ; width: 48px; height: 48px;"/>
				</a>
				</td>
				<td style="text-align: center;">
				<a href="http://technorati.com/faves?add=http://deserialized.com/the-state-of-mongodb-and-csharp/" rel="nofollow">
				<img src="http://deserialized.com/wp-content/plugins/addtothis/technorati.png" alt="Add to Technorati Favorites" style="border: 0px solid ; width: 48px; height: 48px;"/>
				</a>
				</td>
				<td style="text-align: center;">
				<a href="http://www.stumbleupon.com/submit?url=http://deserialized.com/the-state-of-mongodb-and-csharp/&title=The Current State of MongoDB and C#" rel="nofollow">
				<img src="http://deserialized.com/wp-content/plugins/addtothis/stumble.png" alt="Stumble It!" style="border: 0px solid ; width: 48px; height: 48px;"/>
				</a>
				
				</td>
				<td style="text-align: center;">
				<a href="http://digg.com/submit?phase=2&url=http://deserialized.com/the-state-of-mongodb-and-csharp/" rel="nofollow">
				<img src="http://deserialized.com/wp-content/plugins/addtothis/digg.png" alt="Digg It!" style="border: 0px solid ; width: 48px; height: 48px;"/>
				</a>
				
				</td>
				</tr>
				<tr><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td style="text-align: right;" ><a href="http://www.sajithmr.com"><img style="border:none" src="http://deserialized.com/wp-content/plugins/addtothis/sajithmr.png"  title="Powered By Sajithmr.com" alt="www.sajithmr.com"/></a></td></tr>
				</tbody>
				</table>

                
		
				</p>]]></content:encoded>
			<wfw:commentRss>http://deserialized.com/the-state-of-mongodb-and-csharp/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Gotcha: 32-bit applications may not be able to see files on 64-bit Windows</title>
		<link>http://deserialized.com/gotcha-32-bit-applications-may-not-be-able-to-see-files-on-64-bit-windows/</link>
		<comments>http://deserialized.com/gotcha-32-bit-applications-may-not-be-able-to-see-files-on-64-bit-windows/#comments</comments>
		<pubDate>Thu, 12 Nov 2009 04:29:12 +0000</pubDate>
		<dc:creator>Bryan Migliorisi</dc:creator>
				<category><![CDATA[Gotcha]]></category>
		<category><![CDATA[Windows]]></category>
		<category><![CDATA[iis7]]></category>

		<guid isPermaLink="false">http://deserialized.com/gotcha-32-bit-applications-may-not-be-able-to-see-files-on-64-bit-windows/</guid>
		<description><![CDATA[This one really threw me off tonight.&#160; I am running Windows Server 2008 on one of my boxes and I was trying to set up some advanced URL Routing on IIS7.&#160; IIS7 Manager has a very nice easy to use GUI interface, but I prefer working directly in the configuration files. I fire up my [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fdeserialized.com%2Fgotcha-32-bit-applications-may-not-be-able-to-see-files-on-64-bit-windows%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fdeserialized.com%2Fgotcha-32-bit-applications-may-not-be-able-to-see-files-on-64-bit-windows%2F&amp;source=BryanMigliorisi&amp;style=normal&amp;service=is.gd" height="61" width="50" /><br />
			</a>
		</div>
<p><img style="border-bottom: 0px; border-left: 0px; margin: 0px 40px 0px 0px; display: inline; border-top: 0px; border-right: 0px" title="winlogo-300x265" border="0" alt="winlogo-300x265" align="left" src="http://deserialized.com/wp-content/uploads/2009/11/winlogo300x265.jpg" width="123" height="145" /> This one really threw me off tonight.&#160; I am running Windows Server 2008 on one of my boxes and I was trying to set up some advanced URL Routing on IIS7.&#160; IIS7 Manager has a very nice easy to use GUI interface, but I prefer working directly in the configuration files.</p>
<p>I fire up my Notepad++ and attempt to open a file through the file browser.&#160; I navigate to the IIS config folder (c:\windows\system32\inetsrv\config\) and I see an empty directory.&#160; Huh? How is that possible?!</p>
<p>Now I switch over to Windows Explorer and go to the same folder as above and to my disbelief… there are all the config files.&#160; Ok now I am truly confused!</p>
<h2>Conclusion</h2>
<p>While I cannot seem to find anything from Microsoft about this issue, my findings are that 32-bit applications cannot see the entire file system!&#160; I installed a few applications that I know are only 32-bit to verify this and sure enough they all suffered from the exact same issue.&#160; </p>
<p>Files simply do not show up and if you attempt to open the file (because you do know the full path &amp; filename), it simply tells you that the file does not exist.</p>
<p>
				<table cellspacing="0" cellpadding="0" border="0" style="width: 300px; height: 50px; text-align: left; margin-left: auto; margin-right: auto;">
				<tbody>
				<tr>
				<td style="text-align: center;">
				<a href="http://del.icio.us/post?url=http://deserialized.com/gotcha-32-bit-applications-may-not-be-able-to-see-files-on-64-bit-windows/&title=Gotcha: 32-bit applications may not be able to see files on 64-bit Windows" rel="nofollow">
				<img src="http://deserialized.com/wp-content/plugins/addtothis/delicious.png" alt="Add to Del.cio.us" style="border: 0px solid ; width: 48px; height: 48px;"/>
				</a>
				</td>
				<td style="text-align: center;">
				<a href="http://deserialized.com/feed/rss/" rel="nofollow">
				<img src="http://deserialized.com/wp-content/plugins/addtothis/feeds.png" alt="RSS Feed" style="border: 0px solid ; width: 48px; height: 48px;"/>
				</a>
				</td>
				<td style="text-align: center;">
				<a href="http://technorati.com/faves?add=http://deserialized.com/gotcha-32-bit-applications-may-not-be-able-to-see-files-on-64-bit-windows/" rel="nofollow">
				<img src="http://deserialized.com/wp-content/plugins/addtothis/technorati.png" alt="Add to Technorati Favorites" style="border: 0px solid ; width: 48px; height: 48px;"/>
				</a>
				</td>
				<td style="text-align: center;">
				<a href="http://www.stumbleupon.com/submit?url=http://deserialized.com/gotcha-32-bit-applications-may-not-be-able-to-see-files-on-64-bit-windows/&title=Gotcha: 32-bit applications may not be able to see files on 64-bit Windows" rel="nofollow">
				<img src="http://deserialized.com/wp-content/plugins/addtothis/stumble.png" alt="Stumble It!" style="border: 0px solid ; width: 48px; height: 48px;"/>
				</a>
				
				</td>
				<td style="text-align: center;">
				<a href="http://digg.com/submit?phase=2&url=http://deserialized.com/gotcha-32-bit-applications-may-not-be-able-to-see-files-on-64-bit-windows/" rel="nofollow">
				<img src="http://deserialized.com/wp-content/plugins/addtothis/digg.png" alt="Digg It!" style="border: 0px solid ; width: 48px; height: 48px;"/>
				</a>
				
				</td>
				</tr>
				<tr><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td style="text-align: right;" ><a href="http://www.sajithmr.com"><img style="border:none" src="http://deserialized.com/wp-content/plugins/addtothis/sajithmr.png"  title="Powered By Sajithmr.com" alt="www.sajithmr.com"/></a></td></tr>
				</tbody>
				</table>

                
		
				</p>]]></content:encoded>
			<wfw:commentRss>http://deserialized.com/gotcha-32-bit-applications-may-not-be-able-to-see-files-on-64-bit-windows/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Reverse Proxy Performance &#8211; Varnish vs. Squid (Part 2)</title>
		<link>http://deserialized.com/reverse-proxy-performance-varnish-vs-squid-part-2/</link>
		<comments>http://deserialized.com/reverse-proxy-performance-varnish-vs-squid-part-2/#comments</comments>
		<pubDate>Wed, 09 Sep 2009 01:32:38 +0000</pubDate>
		<dc:creator>Bryan Migliorisi</dc:creator>
				<category><![CDATA[Caching]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[Varnish]]></category>

		<guid isPermaLink="false">http://deserialized.com/?p=37</guid>
		<description><![CDATA[In part one of this series I tested the raw throughput performance of Varnish and Squid.  My results are consistent with all the blogs and comments floating around the blogosphere – Varnish blows away Squid. Unfortunately, the first series of tests were somewhat uninformative.  Since they only tested the raw performance of serving cached content [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fdeserialized.com%2Freverse-proxy-performance-varnish-vs-squid-part-2%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fdeserialized.com%2Freverse-proxy-performance-varnish-vs-squid-part-2%2F&amp;source=BryanMigliorisi&amp;style=normal&amp;service=is.gd" height="61" width="50" /><br />
			</a>
		</div>
<p><img style="border-right-width: 0px; margin: 0px 20px 0px 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="squid-vs-varnish" src="http://deserialized.com/wp-content/uploads/2009/09/squidvsvarnish.gif" border="0" alt="squid-vs-varnish" width="133" height="153" align="left" /></p>
<p>In <a title="Reverse Proxy Performance – Varnish vs. Squid (Part 1)" href="http://deserialized.com/reverse-proxy-performance-varnish-vs-squid-part-1/">part one</a> of this series I tested the raw throughput performance of <a title="Varnish is a state-of-the-art, high-performance HTTP accelerator" href="http://varnish.projects.linpro.no/">Varnish</a> and <a href="http://www.squid-cache.org/">Squid</a>.  My results are consistent with all the blogs and comments floating around the blogosphere – Varnish blows away Squid.</p>
<p>Unfortunately, the first series of tests were somewhat uninformative.  Since they only tested the raw performance of serving cached content from memory, it did not mimic a real world scenario of serving cached content as well as fetching content from the backend and caching it.</p>
<p>While we would hope for a primed, full cache, it is unlikely to happen and you will undoubtedly see a decent amount of backend requests from your caching proxy.</p>
<p>A better test of the two proxies would involve a large set of random URLs, but not <em>too</em> random because we want to simulate both cache hits and cache misses.  To accomplish this, I wrote a small PHP script that would take two parameters: total number of URLs to generate and the hostname for those URLs.</p>
<h2>Generating a usable URL list</h2>
<p>Generating the list is simple.  This script looks like this:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
        <span style="color: #990000;">ob_start</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$total</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'total'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$host</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'host'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> <span style="color: #000088;">$i</span> <span style="color: #339933;">&lt;</span> <span style="color: #000088;">$total</span><span style="color: #339933;">;</span> <span style="color: #000088;">$i</span><span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #666666; font-style: italic;">// generate random numbers</span>
                <span style="color: #990000;">srand</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">time</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #000088;">$random</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mt_rand</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">10</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">40</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #000088;">$random2</span> <span style="color: #339933;">=</span>  <span style="color: #990000;">mt_rand</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">100</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
                <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">substr</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$random2</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$as</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;?as=<span style="color: #006699; font-weight: bold;">$random2</span>&quot;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$as</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
                <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;http://<span style="color: #006699; font-weight: bold;">$host</span>/varnish/gen/<span style="color: #006699; font-weight: bold;">$random</span><span style="color: #006699; font-weight: bold;">$as</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
                <span style="color: #990000;">flush</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #990000;">ob_flush</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
        <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;http://<span style="color: #006699; font-weight: bold;">$host</span>/varnish/gen/<span style="color: #006699; font-weight: bold;">$random</span><span style="color: #006699; font-weight: bold;">$as</span>&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>All this does is create a long list of URLs.  I used PHPs output buffering mechanisms to flush the buffer which is necessary when creating large URL lists so that you don’t wait forever.  Maybe it could have been written better but I don&#8217;t care – that wasn&#8217;t the point of this test.</p>
<p>The URLs that are created are in the format of:</p>
<pre>http://host/varnish/gen/50?as=100

http://host/varnish/gen/50</pre>
<p>This URL is mapped to another PHP file that simply generates dummy data of the size specified in the URL.  In the above cases, the files would be 50Kb large.  The query parameter “as” is just a useless piece of information that is meant to tell the proxy to cache it.  If the “as” query parameter does not exist, the proxy will forward the request to the backend and not cache it.  Its a simple way to generate cacheable and non-cacheable URLs.</p>
<p>To generate the list and store it in a local file, I used this command:</p>
<pre>curl http://192.168.165.101/varnish/makelist.php?total=10000&amp;host=192.168.165.104:8080
	&gt; urls-10k.txt</pre>
<p><strong>Verify the results of the script</strong></p>
<p>For your own sanity, make sure that the script did in fact generate a list of URLs that suits your needs.</p>
<p>Count the amount of URLs generated:</p>
<pre>cat urls-10k.txt | wc –l</pre>
<p>(yes, I know it creates one extra URL … Its fine by me.)</p>
<p>Count the amount of cacheable URLs containing the “as” query parameter:</p>
<pre>cat urls-10k.txt | grep as | wc –l</pre>
<p>Count the amount of unique cacheable URLs:</p>
<pre>cat urls-10k.txt | grep as | sort | uniq | wc –l</pre>
<h2>Running the tests</h2>
<p>In part one I used ApacheBench to load the servers but for these tests, I used <a title="Siege is an http regression testing and benchmarking utility" href="http://www.joedog.org/index/siege-home">Siege</a> and <a title="http_load runs multiple http fetches in parallel, to test the throughput of a web server" href="http://acme.com/software/http_load/">http_load</a> which both allowed me to load URLs from a file.</p>
<p>I started with Varnish using the following commands:</p>
<pre>curl http://192.168.165.101/varnish/makelist.php?total=100000&amp;host=192.168.165.104:8080
	&gt; urls-100k.txt</pre>
<pre>http_load -parallel 10 -fetches 100000 urls-100k.txt
http_load -parallel 25 -fetches 100000 urls-100k.txt
http_load -parallel 50 -fetches 100000 urls-100k.txt
http_load -parallel 100 -fetches 100000 urls-100k.txt
http_load -parallel 200 -fetches 100000 urls-100k.txt
http_load -parallel 400 -fetches 100000 urls-100k.txt</pre>
<p>In between each http_load command, I restarted the Varnish service so that each test ran with an empty cache.  When I was done with the Varnish tests, I ran the same tests against Squid using the same commands above.</p>
<h2>The results</h2>
<p>The results of these tests represent the typical web application much better than the original tests did.</p>
<p>This first graph shows the average time for the proxy to accept a connection.  As concurrency goes up, it is expected that the time to connect would go up too.  Squid suffers more than Varnish does, but the difference is negligible.</p>
<p><a href="http://deserialized.com/wp-content/uploads/2009/09/image.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" src="http://deserialized.com/wp-content/uploads/2009/09/image_thumb.png" border="0" alt="image" width="580" height="188" /></a></p>
<p>The second graph is much more interesting.  As concurrency goes up, the Time-To-First-Byte for Squid goes up very sharply while Varnish holds its ground and remains very quick around 25ms.</p>
<p><a href="http://deserialized.com/wp-content/uploads/2009/09/image1.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" src="http://deserialized.com/wp-content/uploads/2009/09/image_thumb1.png" border="0" alt="image" width="579" height="188" /></a></p>
<p>This third graph shows another interesting behavior.  As concurrency goes up, Varnish begins to even itself out at just under 800 fetches per second while Squid peaks at around 1100 fetches per second with around 50 concurrent connects and then sharply drops off as concurrency goes up.</p>
<p><a href="http://deserialized.com/wp-content/uploads/2009/09/image2.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" src="http://deserialized.com/wp-content/uploads/2009/09/image_thumb2.png" border="0" alt="image" width="579" height="187" /></a></p>
<h2>Conclusion</h2>
<p>Squid versus Varnish is just another holy war that may never end.  The tests that I have performed have been very helpful for me and my team but your results may vary.  Of course, there are many more things to consider and I plan to write about some of the major differences between Squid and Varnish.</p>
<p>My results show that in raw cache hit performance, Varnish puts Squid to shame.  In real world scenarios I found that Squid can hold its own when dealing with small amounts of traffic, but it’s performance drops off very sharply as it begins to handle more connections. Varnish handles them without a sweat, as it was designed to do.</p>
<p>My next blog post will detail the differences between Varnish and Squid’s architecture, features, and the reasons I am pushing for Varnish in our environment.</p>
<p><strong>Edit:</strong></p>
<p>Some people are complaining in comments on Reddit and HackerNews that I have not provided any information about the hardware or operating system for my tests.  This information was posted in <a href="http://deserialized.com/reverse-proxy-performance-varnish-vs-squid-part-1/">Part one</a> of this post.</p>
<p>
				<table cellspacing="0" cellpadding="0" border="0" style="width: 300px; height: 50px; text-align: left; margin-left: auto; margin-right: auto;">
				<tbody>
				<tr>
				<td style="text-align: center;">
				<a href="http://del.icio.us/post?url=http://deserialized.com/reverse-proxy-performance-varnish-vs-squid-part-2/&title=Reverse Proxy Performance &ndash; Varnish vs. Squid (Part 2)" rel="nofollow">
				<img src="http://deserialized.com/wp-content/plugins/addtothis/delicious.png" alt="Add to Del.cio.us" style="border: 0px solid ; width: 48px; height: 48px;"/>
				</a>
				</td>
				<td style="text-align: center;">
				<a href="http://deserialized.com/feed/rss/" rel="nofollow">
				<img src="http://deserialized.com/wp-content/plugins/addtothis/feeds.png" alt="RSS Feed" style="border: 0px solid ; width: 48px; height: 48px;"/>
				</a>
				</td>
				<td style="text-align: center;">
				<a href="http://technorati.com/faves?add=http://deserialized.com/reverse-proxy-performance-varnish-vs-squid-part-2/" rel="nofollow">
				<img src="http://deserialized.com/wp-content/plugins/addtothis/technorati.png" alt="Add to Technorati Favorites" style="border: 0px solid ; width: 48px; height: 48px;"/>
				</a>
				</td>
				<td style="text-align: center;">
				<a href="http://www.stumbleupon.com/submit?url=http://deserialized.com/reverse-proxy-performance-varnish-vs-squid-part-2/&title=Reverse Proxy Performance &ndash; Varnish vs. Squid (Part 2)" rel="nofollow">
				<img src="http://deserialized.com/wp-content/plugins/addtothis/stumble.png" alt="Stumble It!" style="border: 0px solid ; width: 48px; height: 48px;"/>
				</a>
				
				</td>
				<td style="text-align: center;">
				<a href="http://digg.com/submit?phase=2&url=http://deserialized.com/reverse-proxy-performance-varnish-vs-squid-part-2/" rel="nofollow">
				<img src="http://deserialized.com/wp-content/plugins/addtothis/digg.png" alt="Digg It!" style="border: 0px solid ; width: 48px; height: 48px;"/>
				</a>
				
				</td>
				</tr>
				<tr><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td style="text-align: right;" ><a href="http://www.sajithmr.com"><img style="border:none" src="http://deserialized.com/wp-content/plugins/addtothis/sajithmr.png"  title="Powered By Sajithmr.com" alt="www.sajithmr.com"/></a></td></tr>
				</tbody>
				</table>

                
		
				</p>]]></content:encoded>
			<wfw:commentRss>http://deserialized.com/reverse-proxy-performance-varnish-vs-squid-part-2/feed/</wfw:commentRss>
		<slash:comments>26</slash:comments>
		</item>
		<item>
		<title>Reverse Proxy Performance &#8211; Varnish vs. Squid (Part 1)</title>
		<link>http://deserialized.com/reverse-proxy-performance-varnish-vs-squid-part-1/</link>
		<comments>http://deserialized.com/reverse-proxy-performance-varnish-vs-squid-part-1/#comments</comments>
		<pubDate>Thu, 03 Sep 2009 01:15:57 +0000</pubDate>
		<dc:creator>Bryan Migliorisi</dc:creator>
				<category><![CDATA[Caching]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[Varnish]]></category>

		<guid isPermaLink="false">http://deserialized.com/?p=30</guid>
		<description><![CDATA[Typical web applications require dozens of SQL queries to generate a single page.&#160; When your application is serving over 1,000,000 pages per day, you quickly realize that the performance bottleneck is your database.&#160; The typical answer to slow database queries is “just use memcached!”&#160; Memcached and other data caches can only take you so far.&#160; [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fdeserialized.com%2Freverse-proxy-performance-varnish-vs-squid-part-1%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fdeserialized.com%2Freverse-proxy-performance-varnish-vs-squid-part-1%2F&amp;source=BryanMigliorisi&amp;style=normal&amp;service=is.gd" height="61" width="50" /><br />
			</a>
		</div>
<p><img style="border-bottom: 0px; border-left: 0px; margin: 0px 20px 0px 0px; display: inline; border-top: 0px; border-right: 0px" title="squid-vs-varnish" border="0" alt="squid-vs-varnish" align="left" src="http://deserialized.com/wp-content/uploads/2009/09/squidvsvarnish.gif" width="133" height="153" /> Typical web applications require dozens of SQL queries to generate a single page.&#160; When your application is serving over 1,000,000 pages per day, you quickly realize that the performance bottleneck is your database.&#160; The typical answer to slow database queries is “just use <a href="http://www.danga.com/memcached/">memcached</a>!”&#160; <a href="http://www.danga.com/memcached/">Memcached</a> and other data caches can only take you so far.&#160; This is where reverse proxies come in.&#160; There are a handful of them out there, including <a title="nginx [engine x] is a HTTP server and mail proxy server" href="http://nginx.net/">Nginx</a>, <a title="Perlbal is a Perl-based reverse proxy load balancer and web server" href="http://www.danga.com/perlbal/">Perlbal</a>, <a title="Squid is a caching proxy for the Web supporting HTTP, HTTPS, FTP, and more" href="http://www.squid-cache.org/">Squid</a> and <a title="Varnish is a state-of-the-art, high-performance HTTP accelerator. It uses the advanced features in Linux 2.6, FreeBSD 6/7 and Solaris 10 to achieve its high performance." href="http://varnish.projects.linpro.no/">Varnish</a>.&#160; Which to use is up to you.</p>
<p>&#160;</p>
<h2>Deciding what is best for you</h2>
<p>Assuming that you have taken a step back and really analyzed your problem first, the next step is to analyze the possible solutions.&#160; For us, Varnish seems like the best option with Squid close behind.&#160; To be fair, I’ve set up a test server with both Varnish and Squid running.&#160; I’ll use <a title="ab is a tool for benchmarking your Apache Hypertext Transfer Protocol (HTTP) server" href="http://httpd.apache.org/docs/2.0/programs/ab.html">ApacheBench</a> to generate load and requests.</p>
<p>I’ve analyzed our pages to see what the typical page size is and recorded the average page sizes for 5 different page types.&#160; They range from around 10KB to 35KB (<a href="http://developer.yahoo.com/performance/rules.html#gzip">gzipped</a>).&#160; For my test, I’ll be benchmarking with 10KB, 15KB, 20KB, 30KB, 40KB, and 50KB files to get a good range of different size requests.</p>
<p>To test under different load capacities, I’ll use <a title="ab is a tool for benchmarking your Apache Hypertext Transfer Protocol (HTTP) server" href="http://httpd.apache.org/docs/2.0/programs/ab.html">ApacheBench</a> to generate loads with different amounts of concurrent users ranging from 10 to 400.</p>
<p>&#160;</p>
<h2>The test</h2>
<p>I’ll be using two identical machines on the same local class C network to eliminate (as much as possible) network latency.&#160; </p>
<p><strong>The machines look something like this:</strong></p>
<ul>
<li>Pentium 4 3GHz (8KB Level 1, 512KB Level 2) </li>
<li>2GB (4&#215;512 DDR 400MHz) </li>
<li>120GB ATA Western Digital Caviar WD1200JB </li>
<li>CentOS 5 </li>
</ul>
<p>(I don&#8217;t have more information than that.&#160; Suffice to say that it is a few years old and not very powerful)</p>
<p>I am using Varnish 2.04 and Squid 2.6.STABLE21.&#160; There are newer versions of Squid but i am using this version because the 3.x branch is missing features found in the 2.x branch and I have read several reports of 2.7 crashing, etc.</p>
<p>&#160;</p>
<p><strong>The command to run the load test looks something like this:</strong></p>
<p>ab –c concurrent_users –n total_requests “url”</p>
<p>This will let you specify how many concurrent users to run and how many requests to make.&#160; I have the proxy servers running on ServerA and I run the benchmark from ServerB.</p>
<p>&#160;</p>
<h2>The results</h2>
<p>In general, Varnish seems to perform twice as well as Squid does.&#160; In every test, Varnish serves nearly 2x more requests per second and has half the average response time.</p>
<table border="2" cellspacing="0">
<tbody>
<tr valign="bottom">
<td class="style1" colspan="2" align="center">&#160;</td>
<td class="style1" bgcolor="#d7e4bd" valign="middle" colspan="3" align="center"><font color="#9bbb59" size="5" face="Calibri"><b>Varnish</b></font></td>
<td class="style1" bgcolor="#d7e4bd" valign="middle" colspan="3" align="center"><font color="#9bbb59" size="5" face="Calibri"><b>Squid</b></font></td>
</tr>
<tr valign="bottom">
<td valign="middle" width="40" align="center"><font size="3" face="Calibri">File Size</font></td>
<td valign="middle" width="59" align="center"><font size="3" face="Calibri">Concurrent Users</font></td>
<td valign="middle" width="58" align="center"><font size="3" face="Calibri">(V) Requests per second</font></td>
<td valign="middle" width="64" align="center"><font size="3" face="Calibri">(V) Avg across all requests</font></td>
<td valign="middle" width="60" align="center"><font size="3" face="Calibri">(V) Average Request (ms)</font></td>
<td valign="middle" width="59" align="center"><font size="3" face="Calibri">(S) Requests per second</font></td>
<td valign="middle" width="65" align="center"><font size="3" face="Calibri">(S) Avg across all requests</font></td>
<td valign="middle" width="57" align="center"><font size="3" face="Calibri">(S) Average Request (ms)</font></td>
</tr>
<tr valign="bottom">
<td width="40" align="center"><font size="3" face="Calibri">10k</font></td>
<td width="59" align="center"><font size="3" face="Calibri">10</font></td>
<td width="58" align="center"><font size="3" face="Calibri">6592</font></td>
<td width="64" align="center"><font size="3" face="Calibri">0.152</font></td>
<td width="60" align="center"><font size="3" face="Calibri">1</font></td>
<td width="59" align="center"><font size="3" face="Calibri">3078</font></td>
<td width="65" align="center"><font size="3" face="Calibri">0.325</font></td>
<td width="57" align="center"><font size="3" face="Calibri">3</font></td>
</tr>
<tr valign="bottom">
<td width="40" align="center"><font size="3" face="Calibri">10k</font></td>
<td width="59" align="center"><font size="3" face="Calibri">25</font></td>
<td width="58" align="center"><font size="3" face="Calibri">6915</font></td>
<td width="64" align="center"><font size="3" face="Calibri">0.145</font></td>
<td width="60" align="center"><font size="3" face="Calibri">3</font></td>
<td width="59" align="center"><font size="3" face="Calibri">3568</font></td>
<td width="65" align="center"><font size="3" face="Calibri">0.280</font></td>
<td width="57" align="center"><font size="3" face="Calibri">7</font></td>
</tr>
<tr valign="bottom">
<td width="40" align="center"><font size="3" face="Calibri">10k</font></td>
<td width="59" align="center"><font size="3" face="Calibri">50</font></td>
<td width="58" align="center"><font size="3" face="Calibri">7071</font></td>
<td width="64" align="center"><font size="3" face="Calibri">0.141</font></td>
<td width="60" align="center"><font size="3" face="Calibri">7</font></td>
<td width="59" align="center"><font size="3" face="Calibri">3539</font></td>
<td width="65" align="center"><font size="3" face="Calibri">0.283</font></td>
<td width="57" align="center"><font size="3" face="Calibri">14</font></td>
</tr>
<tr valign="bottom">
<td width="40" align="center"><font size="3" face="Calibri">10k</font></td>
<td width="59" align="center"><font size="3" face="Calibri">100</font></td>
<td width="58" align="center"><font size="3" face="Calibri">6860</font></td>
<td width="64" align="center"><font size="3" face="Calibri">0.146</font></td>
<td width="60" align="center"><font size="3" face="Calibri">13</font></td>
<td width="59" align="center"><font size="3" face="Calibri">3565</font></td>
<td width="65" align="center"><font size="3" face="Calibri">0.280</font></td>
<td width="57" align="center"><font size="3" face="Calibri">28</font></td>
</tr>
<tr valign="bottom">
<td width="40" align="center"><font size="3" face="Calibri">10k</font></td>
<td width="59" align="center"><font size="3" face="Calibri">200</font></td>
<td width="58" align="center"><font size="3" face="Calibri">7252</font></td>
<td width="64" align="center"><font size="3" face="Calibri">0.138</font></td>
<td width="60" align="center"><font size="3" face="Calibri">27</font></td>
<td width="59" align="center"><font size="3" face="Calibri">3506</font></td>
<td width="65" align="center"><font size="3" face="Calibri">0.285</font></td>
<td width="57" align="center"><font size="3" face="Calibri">57</font></td>
</tr>
<tr valign="bottom">
<td width="40" align="center"><font size="3" face="Calibri">10k</font></td>
<td width="59" align="center"><font size="3" face="Calibri">400</font></td>
<td width="58" align="center"><font size="3" face="Calibri">7181</font></td>
<td width="64" align="center"><font size="3" face="Calibri">0.139</font></td>
<td width="60" align="center"><font size="3" face="Calibri">56</font></td>
<td width="59" align="center"><font size="3" face="Calibri">3518</font></td>
<td width="65" align="center"><font size="3" face="Calibri">0.284</font></td>
<td width="57" align="center"><font size="3" face="Calibri">113</font></td>
</tr>
<tr valign="bottom">
<td bgcolor="#748c42" width="40">&#160;</td>
<td bgcolor="#748c42" width="59"></td>
<td bgcolor="#748c42" width="58"></td>
<td bgcolor="#748c42" width="64"></td>
<td bgcolor="#748c42" width="60"></td>
<td bgcolor="#748c42" width="59"></td>
<td bgcolor="#748c42" width="65"></td>
<td bgcolor="#748c42" width="57"></td>
</tr>
<tr valign="bottom">
<td width="40" align="center"><font size="3" face="Calibri">15k</font></td>
<td width="59" align="center"><font size="3" face="Calibri">10</font></td>
<td width="58" align="center"><font size="3" face="Calibri">4636</font></td>
<td width="64" align="center"><font size="3" face="Calibri">0.216</font></td>
<td width="60" align="center"><font size="3" face="Calibri">2</font></td>
<td width="59" align="center"><font size="3" face="Calibri">2949</font></td>
<td width="65" align="center"><font size="3" face="Calibri">0.339</font></td>
<td width="57" align="center"><font size="3" face="Calibri">3</font></td>
</tr>
<tr valign="bottom">
<td width="40" align="center"><font size="3" face="Calibri">15k</font></td>
<td width="59" align="center"><font size="3" face="Calibri">25</font></td>
<td width="58" align="center"><font size="3" face="Calibri">5954</font></td>
<td width="64" align="center"><font size="3" face="Calibri">0.168</font></td>
<td width="60" align="center"><font size="3" face="Calibri">4</font></td>
<td width="59" align="center"><font size="3" face="Calibri">3168</font></td>
<td width="65" align="center"><font size="3" face="Calibri">0.316</font></td>
<td width="57" align="center"><font size="3" face="Calibri">7</font></td>
</tr>
<tr valign="bottom">
<td width="40" align="center"><font size="3" face="Calibri">15k</font></td>
<td width="59" align="center"><font size="3" face="Calibri">50</font></td>
<td width="58" align="center"><font size="3" face="Calibri">6036</font></td>
<td width="64" align="center"><font size="3" face="Calibri">0.166</font></td>
<td width="60" align="center"><font size="3" face="Calibri">8</font></td>
<td width="59" align="center"><font size="3" face="Calibri">3118</font></td>
<td width="65" align="center"><font size="3" face="Calibri">0.321</font></td>
<td width="57" align="center"><font size="3" face="Calibri">16</font></td>
</tr>
<tr valign="bottom">
<td width="40" align="center"><font size="3" face="Calibri">15k</font></td>
<td width="59" align="center"><font size="3" face="Calibri">100</font></td>
<td width="58" align="center"><font size="3" face="Calibri">6060</font></td>
<td width="64" align="center"><font size="3" face="Calibri">0.165</font></td>
<td width="60" align="center"><font size="3" face="Calibri">16</font></td>
<td width="59" align="center"><font size="3" face="Calibri">3247</font></td>
<td width="65" align="center"><font size="3" face="Calibri">0.308</font></td>
<td width="57" align="center"><font size="3" face="Calibri">30</font></td>
</tr>
<tr valign="bottom">
<td width="40" align="center"><font size="3" face="Calibri">15k</font></td>
<td width="59" align="center"><font size="3" face="Calibri">200</font></td>
<td width="58" align="center"><font size="3" face="Calibri">6066</font></td>
<td width="64" align="center"><font size="3" face="Calibri">0.165</font></td>
<td width="60" align="center"><font size="3" face="Calibri">32</font></td>
<td width="59" align="center"><font size="3" face="Calibri">3226</font></td>
<td width="65" align="center"><font size="3" face="Calibri">0.310</font></td>
<td width="57" align="center"><font size="3" face="Calibri">61</font></td>
</tr>
<tr valign="bottom">
<td width="40" align="center"><font size="3" face="Calibri">15k</font></td>
<td width="59" align="center"><font size="3" face="Calibri">400</font></td>
<td width="58" align="center"><font size="3" face="Calibri">6048</font></td>
<td width="64" align="center"><font size="3" face="Calibri">0.165</font></td>
<td width="60" align="center"><font size="3" face="Calibri">66</font></td>
<td width="59" align="center"><font size="3" face="Calibri">3092</font></td>
<td width="65" align="center"><font size="3" face="Calibri">0.323</font></td>
<td width="57" align="center"><font size="3" face="Calibri">129</font></td>
</tr>
<tr valign="bottom">
<td bgcolor="#748c42" width="40">&#160;</td>
<td bgcolor="#748c42" width="59"></td>
<td bgcolor="#748c42" width="58"></td>
<td bgcolor="#748c42" width="64"></td>
<td bgcolor="#748c42" width="60"></td>
<td bgcolor="#748c42" width="59"></td>
<td bgcolor="#748c42" width="65"></td>
<td bgcolor="#748c42" width="57"></td>
</tr>
<tr valign="bottom">
<td width="40" align="center"><font size="3" face="Calibri">20k</font></td>
<td width="59" align="center"><font size="3" face="Calibri">10</font></td>
<td width="58" align="center"><font size="3" face="Calibri">4689</font></td>
<td width="64" align="center"><font size="3" face="Calibri">0.213</font></td>
<td width="60" align="center"><font size="3" face="Calibri">2</font></td>
<td width="59" align="center"><font size="3" face="Calibri">2553</font></td>
<td width="65" align="center"><font size="3" face="Calibri">0.392</font></td>
<td width="57" align="center"><font size="3" face="Calibri">3</font></td>
</tr>
<tr valign="bottom">
<td width="40" align="center"><font size="3" face="Calibri">20k</font></td>
<td width="59" align="center"><font size="3" face="Calibri">25</font></td>
<td width="58" align="center"><font size="3" face="Calibri">5342</font></td>
<td width="64" align="center"><font size="3" face="Calibri">0.187</font></td>
<td width="60" align="center"><font size="3" face="Calibri">4</font></td>
<td width="59" align="center"><font size="3" face="Calibri">2675</font></td>
<td width="65" align="center"><font size="3" face="Calibri">0.374</font></td>
<td width="57" align="center"><font size="3" face="Calibri">9</font></td>
</tr>
<tr valign="bottom">
<td width="40" align="center"><font size="3" face="Calibri">20k</font></td>
<td width="59" align="center"><font size="3" face="Calibri">50</font></td>
<td width="58" align="center"><font size="3" face="Calibri">5422</font></td>
<td width="64" align="center"><font size="3" face="Calibri">0.184</font></td>
<td width="60" align="center"><font size="3" face="Calibri">9</font></td>
<td width="59" align="center"><font size="3" face="Calibri">2799</font></td>
<td width="65" align="center"><font size="3" face="Calibri">0.357</font></td>
<td width="57" align="center"><font size="3" face="Calibri">17</font></td>
</tr>
<tr valign="bottom">
<td width="40" align="center"><font size="3" face="Calibri">20k</font></td>
<td width="59" align="center"><font size="3" face="Calibri">100</font></td>
<td width="58" align="center"><font size="3" face="Calibri">5446</font></td>
<td width="64" align="center"><font size="3" face="Calibri">0.184</font></td>
<td width="60" align="center"><font size="3" face="Calibri">18</font></td>
<td width="59" align="center"><font size="3" face="Calibri">2861</font></td>
<td width="65" align="center"><font size="3" face="Calibri">0.349</font></td>
<td width="57" align="center"><font size="3" face="Calibri">34</font></td>
</tr>
<tr valign="bottom">
<td width="40" align="center"><font size="3" face="Calibri">20k</font></td>
<td width="59" align="center"><font size="3" face="Calibri">200</font></td>
<td width="58" align="center"><font size="3" face="Calibri">5430</font></td>
<td width="64" align="center"><font size="3" face="Calibri">0.184</font></td>
<td width="60" align="center"><font size="3" face="Calibri">36</font></td>
<td width="59" align="center"><font size="3" face="Calibri">2795</font></td>
<td width="65" align="center"><font size="3" face="Calibri">0.358</font></td>
<td width="57" align="center"><font size="3" face="Calibri">71</font></td>
</tr>
<tr valign="bottom">
<td width="40" align="center"><font size="3" face="Calibri">20k</font></td>
<td width="59" align="center"><font size="3" face="Calibri">400</font></td>
<td width="58" align="center"><font size="3" face="Calibri">5400</font></td>
<td width="64" align="center"><font size="3" face="Calibri">0.185</font></td>
<td width="60" align="center"><font size="3" face="Calibri">74</font></td>
<td width="59" align="center"><font size="3" face="Calibri">2656</font></td>
<td width="65" align="center"><font size="3" face="Calibri">0.376</font></td>
<td width="57" align="center"><font size="3" face="Calibri">150</font></td>
</tr>
<tr valign="bottom">
<td bgcolor="#748c42" width="40">&#160;</td>
<td bgcolor="#748c42" width="59"></td>
<td bgcolor="#748c42" width="58"></td>
<td bgcolor="#748c42" width="64"></td>
<td bgcolor="#748c42" width="60"></td>
<td bgcolor="#748c42" width="59"></td>
<td bgcolor="#748c42" width="65"></td>
<td bgcolor="#748c42" width="57"></td>
</tr>
<tr valign="bottom">
<td width="40" align="center"><font size="3" face="Calibri">25k</font></td>
<td width="59" align="center"><font size="3" face="Calibri">10</font></td>
<td width="58" align="center"><font size="3" face="Calibri">4135</font></td>
<td width="64" align="center"><font size="3" face="Calibri">0.242</font></td>
<td width="60" align="center"><font size="3" face="Calibri">2</font></td>
<td width="59" align="center"><font size="3" face="Calibri">2331</font></td>
<td width="65" align="center"><font size="3" face="Calibri">0.429</font></td>
<td width="57" align="center"><font size="3" face="Calibri">4</font></td>
</tr>
<tr valign="bottom">
<td width="40" align="center"><font size="3" face="Calibri">25k</font></td>
<td width="59" align="center"><font size="3" face="Calibri">25</font></td>
<td width="58" align="center"><font size="3" face="Calibri">4485</font></td>
<td width="64" align="center"><font size="3" face="Calibri">0.223</font></td>
<td width="60" align="center"><font size="3" face="Calibri">5</font></td>
<td width="59" align="center"><font size="3" face="Calibri">2308</font></td>
<td width="65" align="center"><font size="3" face="Calibri">0.433</font></td>
<td width="57" align="center"><font size="3" face="Calibri">10</font></td>
</tr>
<tr valign="bottom">
<td width="40" align="center"><font size="3" face="Calibri">25k</font></td>
<td width="59" align="center"><font size="3" face="Calibri">50</font></td>
<td width="58" align="center"><font size="3" face="Calibri">4488</font></td>
<td width="64" align="center"><font size="3" face="Calibri">0.223</font></td>
<td width="60" align="center"><font size="3" face="Calibri">11</font></td>
<td width="59" align="center"><font size="3" face="Calibri">2221</font></td>
<td width="65" align="center"><font size="3" face="Calibri">0.450</font></td>
<td width="57" align="center"><font size="3" face="Calibri">22</font></td>
</tr>
<tr valign="bottom">
<td width="40" align="center"><font size="3" face="Calibri">25k</font></td>
<td width="59" align="center"><font size="3" face="Calibri">100</font></td>
<td width="58" align="center"><font size="3" face="Calibri">4446</font></td>
<td width="64" align="center"><font size="3" face="Calibri">0.225</font></td>
<td width="60" align="center"><font size="3" face="Calibri">22</font></td>
<td width="59" align="center"><font size="3" face="Calibri">2217</font></td>
<td width="65" align="center"><font size="3" face="Calibri">0.451</font></td>
<td width="57" align="center"><font size="3" face="Calibri">45</font></td>
</tr>
<tr valign="bottom">
<td width="40" align="center"><font size="3" face="Calibri">25k</font></td>
<td width="59" align="center"><font size="3" face="Calibri">200</font></td>
<td width="58" align="center"><font size="3" face="Calibri">4311</font></td>
<td width="64" align="center"><font size="3" face="Calibri">0.232</font></td>
<td width="60" align="center"><font size="3" face="Calibri">46</font></td>
<td width="59" align="center"><font size="3" face="Calibri">2180</font></td>
<td width="65" align="center"><font size="3" face="Calibri">0.459</font></td>
<td width="57" align="center"><font size="3" face="Calibri">91</font></td>
</tr>
<tr valign="bottom">
<td width="40" align="center"><font size="3" face="Calibri">25k</font></td>
<td width="59" align="center"><font size="3" face="Calibri">400</font></td>
<td width="58" align="center"><font size="3" face="Calibri">4160</font></td>
<td width="64" align="center"><font size="3" face="Calibri">0.240</font></td>
<td width="60" align="center"><font size="3" face="Calibri">96</font></td>
<td width="59" align="center"><font size="3" face="Calibri">2026</font></td>
<td width="65" align="center"><font size="3" face="Calibri">0.493</font></td>
<td width="57" align="center"><font size="3" face="Calibri">197</font></td>
</tr>
<tr valign="bottom">
<td bgcolor="#748c42" width="40">&#160;</td>
<td bgcolor="#748c42" width="59"></td>
<td bgcolor="#748c42" width="58"></td>
<td bgcolor="#748c42" width="64"></td>
<td bgcolor="#748c42" width="60"></td>
<td bgcolor="#748c42" width="59"></td>
<td bgcolor="#748c42" width="65"></td>
<td bgcolor="#748c42" width="57"></td>
</tr>
<tr valign="bottom">
<td width="40" align="center"><font size="3" face="Calibri">30k</font></td>
<td width="59" align="center"><font size="3" face="Calibri">10</font></td>
<td width="58" align="center"><font size="3" face="Calibri">3463</font></td>
<td width="64" align="center"><font size="3" face="Calibri">0.289</font></td>
<td width="60" align="center"><font size="3" face="Calibri">2</font></td>
<td width="59" align="center"><font size="3" face="Calibri">1936</font></td>
<td width="65" align="center"><font size="3" face="Calibri">0.516</font></td>
<td width="57" align="center"><font size="3" face="Calibri">5</font></td>
</tr>
<tr valign="bottom">
<td width="40" align="center"><font size="3" face="Calibri">30k</font></td>
<td width="59" align="center"><font size="3" face="Calibri">25</font></td>
<td width="58" align="center"><font size="3" face="Calibri">3689</font></td>
<td width="64" align="center"><font size="3" face="Calibri">0.271</font></td>
<td width="60" align="center"><font size="3" face="Calibri">6</font></td>
<td width="59" align="center"><font size="3" face="Calibri">2002</font></td>
<td width="65" align="center"><font size="3" face="Calibri">0.499</font></td>
<td width="57" align="center"><font size="3" face="Calibri">12</font></td>
</tr>
<tr valign="bottom">
<td width="40" align="center"><font size="3" face="Calibri">30k</font></td>
<td width="59" align="center"><font size="3" face="Calibri">50</font></td>
<td width="58" align="center"><font size="3" face="Calibri">3661</font></td>
<td width="64" align="center"><font size="3" face="Calibri">0.273</font></td>
<td width="60" align="center"><font size="3" face="Calibri">13</font></td>
<td width="59" align="center"><font size="3" face="Calibri">1887</font></td>
<td width="65" align="center"><font size="3" face="Calibri">0.530</font></td>
<td width="57" align="center"><font size="3" face="Calibri">26</font></td>
</tr>
<tr valign="bottom">
<td width="40" align="center"><font size="3" face="Calibri">30k</font></td>
<td width="59" align="center"><font size="3" face="Calibri">100</font></td>
<td width="58" align="center"><font size="3" face="Calibri">3627</font></td>
<td width="64" align="center"><font size="3" face="Calibri">0.276</font></td>
<td width="60" align="center"><font size="3" face="Calibri">27</font></td>
<td width="59" align="center"><font size="3" face="Calibri">1778</font></td>
<td width="65" align="center"><font size="3" face="Calibri">0.562</font></td>
<td width="57" align="center"><font size="3" face="Calibri">56</font></td>
</tr>
<tr valign="bottom">
<td width="40" align="center"><font size="3" face="Calibri">30k</font></td>
<td width="59" align="center"><font size="3" face="Calibri">200</font></td>
<td width="58" align="center"><font size="3" face="Calibri">3589</font></td>
<td width="64" align="center"><font size="3" face="Calibri">0.279</font></td>
<td width="60" align="center"><font size="3" face="Calibri">55</font></td>
<td width="59" align="center"><font size="3" face="Calibri">1746</font></td>
<td width="65" align="center"><font size="3" face="Calibri">0.573</font></td>
<td width="57" align="center"><font size="3" face="Calibri">114</font></td>
</tr>
<tr valign="bottom">
<td width="40" align="center"><font size="3" face="Calibri">30k</font></td>
<td width="59" align="center"><font size="3" face="Calibri">400</font></td>
<td width="58" align="center"><font size="3" face="Calibri">3541</font></td>
<td width="64" align="center"><font size="3" face="Calibri">0.282</font></td>
<td width="60" align="center"><font size="3" face="Calibri">112</font></td>
<td width="59" align="center"><font size="3" face="Calibri">1798</font></td>
<td width="65" align="center"><font size="3" face="Calibri">0.556</font></td>
<td width="57" align="center"><font size="3" face="Calibri">222</font></td>
</tr>
<tr valign="bottom">
<td bgcolor="#748c42" width="40">&#160;</td>
<td bgcolor="#748c42" width="59"></td>
<td bgcolor="#748c42" width="58"></td>
<td bgcolor="#748c42" width="64"></td>
<td bgcolor="#748c42" width="60"></td>
<td bgcolor="#748c42" width="59"></td>
<td bgcolor="#748c42" width="65"></td>
<td bgcolor="#748c42" width="57"></td>
</tr>
<tr valign="bottom">
<td width="40" align="center"><font size="3" face="Calibri">40k</font></td>
<td width="59" align="center"><font size="3" face="Calibri">10</font></td>
<td width="58" align="center"><font size="3" face="Calibri">2752</font></td>
<td width="64" align="center"><font size="3" face="Calibri">0.363</font></td>
<td width="60" align="center"><font size="3" face="Calibri">3</font></td>
<td width="59" align="center"><font size="3" face="Calibri">1602</font></td>
<td width="65" align="center"><font size="3" face="Calibri">0.624</font></td>
<td width="57" align="center"><font size="3" face="Calibri">6</font></td>
</tr>
<tr valign="bottom">
<td width="40" align="center"><font size="3" face="Calibri">40k</font></td>
<td width="59" align="center"><font size="3" face="Calibri">25</font></td>
<td width="58" align="center"><font size="3" face="Calibri">2824</font></td>
<td width="64" align="center"><font size="3" face="Calibri">0.354</font></td>
<td width="60" align="center"><font size="3" face="Calibri">8</font></td>
<td width="59" align="center"><font size="3" face="Calibri">1584</font></td>
<td width="65" align="center"><font size="3" face="Calibri">0.631</font></td>
<td width="57" align="center"><font size="3" face="Calibri">15</font></td>
</tr>
<tr valign="bottom">
<td width="40" align="center"><font size="3" face="Calibri">40k</font></td>
<td width="59" align="center"><font size="3" face="Calibri">50</font></td>
<td width="58" align="center"><font size="3" face="Calibri">2826</font></td>
<td width="64" align="center"><font size="3" face="Calibri">0.354</font></td>
<td width="60" align="center"><font size="3" face="Calibri">17</font></td>
<td width="59" align="center"><font size="3" face="Calibri">1492</font></td>
<td width="65" align="center"><font size="3" face="Calibri">0.670</font></td>
<td width="57" align="center"><font size="3" face="Calibri">33</font></td>
</tr>
<tr valign="bottom">
<td width="40" align="center"><font size="3" face="Calibri">40k</font></td>
<td width="59" align="center"><font size="3" face="Calibri">100</font></td>
<td width="58" align="center"><font size="3" face="Calibri">2827</font></td>
<td width="64" align="center"><font size="3" face="Calibri">0.354</font></td>
<td width="60" align="center"><font size="3" face="Calibri">35</font></td>
<td width="59" align="center"><font size="3" face="Calibri">1551</font></td>
<td width="65" align="center"><font size="3" face="Calibri">0.645</font></td>
<td width="57" align="center"><font size="3" face="Calibri">64</font></td>
</tr>
<tr valign="bottom">
<td width="40" align="center"><font size="3" face="Calibri">40k</font></td>
<td width="59" align="center"><font size="3" face="Calibri">200</font></td>
<td width="58" align="center"><font size="3" face="Calibri">2822</font></td>
<td width="64" align="center"><font size="3" face="Calibri">0.354</font></td>
<td width="60" align="center"><font size="3" face="Calibri">70</font></td>
<td width="59" align="center"><font size="3" face="Calibri">1538</font></td>
<td width="65" align="center"><font size="3" face="Calibri">0.65</font></td>
<td width="57" align="center"><font size="3" face="Calibri">130</font></td>
</tr>
<tr valign="bottom">
<td width="40" align="center"><font size="3" face="Calibri">40k</font></td>
<td width="59" align="center"><font size="3" face="Calibri">400</font></td>
<td width="58" align="center"><font size="3" face="Calibri">2794</font></td>
<td width="64" align="center"><font size="3" face="Calibri">0.358</font></td>
<td width="60" align="center"><font size="3" face="Calibri">143</font></td>
<td width="59" align="center"><font size="3" face="Calibri">1372</font></td>
<td width="65" align="center"><font size="3" face="Calibri">0.728</font></td>
<td width="57" align="center"><font size="3" face="Calibri">291</font></td>
</tr>
<tr valign="bottom">
<td bgcolor="#748c42" width="40">&#160;</td>
<td bgcolor="#748c42" width="59"></td>
<td bgcolor="#748c42" width="58"></td>
<td bgcolor="#748c42" width="64"></td>
<td bgcolor="#748c42" width="60"></td>
<td bgcolor="#748c42" width="59"></td>
<td bgcolor="#748c42" width="65"></td>
<td bgcolor="#748c42" width="57"></td>
</tr>
<tr valign="bottom">
<td width="40" align="center"><font size="3" face="Calibri">50k</font></td>
<td width="59" align="center"><font size="3" face="Calibri">10</font></td>
<td width="58" align="center"><font size="3" face="Calibri">2254</font></td>
<td width="64" align="center"><font size="3" face="Calibri">0.443</font></td>
<td width="60" align="center"><font size="3" face="Calibri">4</font></td>
<td width="59" align="center"><font size="3" face="Calibri">1401</font></td>
<td width="65" align="center"><font size="3" face="Calibri">0.713</font></td>
<td width="57" align="center"><font size="3" face="Calibri">7</font></td>
</tr>
<tr valign="bottom">
<td width="40" align="center"><font size="3" face="Calibri">50k</font></td>
<td width="59" align="center"><font size="3" face="Calibri">25</font></td>
<td width="58" align="center"><font size="3" face="Calibri">2265</font></td>
<td width="64" align="center"><font size="3" face="Calibri">0.441</font></td>
<td width="60" align="center"><font size="3" face="Calibri">11</font></td>
<td width="59" align="center"><font size="3" face="Calibri">1379</font></td>
<td width="65" align="center"><font size="3" face="Calibri">0.725</font></td>
<td width="57" align="center"><font size="3" face="Calibri">18</font></td>
</tr>
<tr valign="bottom">
<td width="40" align="center"><font size="3" face="Calibri">50k</font></td>
<td width="59" align="center"><font size="3" face="Calibri">50</font></td>
<td width="58" align="center"><font size="3" face="Calibri">2266</font></td>
<td width="64" align="center"><font size="3" face="Calibri">0.441</font></td>
<td width="60" align="center"><font size="3" face="Calibri">22</font></td>
<td width="59" align="center"><font size="3" face="Calibri">1368</font></td>
<td width="65" align="center"><font size="3" face="Calibri">0.731</font></td>
<td width="57" align="center"><font size="3" face="Calibri">36</font></td>
</tr>
<tr valign="bottom">
<td width="40" align="center"><font size="3" face="Calibri">50k</font></td>
<td width="59" align="center"><font size="3" face="Calibri">100</font></td>
<td width="58" align="center"><font size="3" face="Calibri">2268</font></td>
<td width="64" align="center"><font size="3" face="Calibri">0.441</font></td>
<td width="60" align="center"><font size="3" face="Calibri">44</font></td>
<td width="59" align="center"><font size="3" face="Calibri">1360</font></td>
<td width="65" align="center"><font size="3" face="Calibri">0.735</font></td>
<td width="57" align="center"><font size="3" face="Calibri">73</font></td>
</tr>
<tr valign="bottom">
<td width="40" align="center"><font size="3" face="Calibri">50k</font></td>
<td width="59" align="center"><font size="3" face="Calibri">200</font></td>
<td width="58" align="center"><font size="3" face="Calibri">2266</font></td>
<td width="64" align="center"><font size="3" face="Calibri">0.441</font></td>
<td width="60" align="center"><font size="3" face="Calibri">88</font></td>
<td width="59" align="center"><font size="3" face="Calibri">1230</font></td>
<td width="65" align="center"><font size="3" face="Calibri">0.813</font></td>
<td width="57" align="center"><font size="3" face="Calibri">162</font></td>
</tr>
<tr valign="bottom">
<td width="40" align="center"><font size="3" face="Calibri">50k</font></td>
<td width="59" align="center"><font size="3" face="Calibri">400</font></td>
<td width="58" align="center"><font size="3" face="Calibri">2267</font></td>
<td width="64" align="center"><font size="3" face="Calibri">0.441</font></td>
<td width="60" align="center"><font size="3" face="Calibri">176</font></td>
<td width="59" align="center"><font size="3" face="Calibri">1216</font></td>
<td width="65" align="center"><font size="3" face="Calibri">0.822</font></td>
<td width="57" align="center"><font size="3" face="Calibri">328</font></td>
</tr>
</tbody>
</table>
<p>Here are the graphs of the above data for easier visualization:</p>
<p><a href="http://deserialized.com/wp-content/uploads/2009/09/varnishsquidbenchmarkreqpersecond2.gif"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="" border="0" alt="" src="http://deserialized.com/wp-content/uploads/2009/09/varnishsquidbenchmarkreqpersecond_thumb2.gif" width="200" height="244" /></a>&#160;&#160;&#160; <a href="http://deserialized.com/wp-content/uploads/2009/09/varnishsquidbenchmarkavgrequesttime2.gif"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="" border="0" alt="" src="http://deserialized.com/wp-content/uploads/2009/09/varnishsquidbenchmarkavgrequesttime_thumb2.gif" width="200" height="244" /></a> </p>
<p>&#160;</p>
<h2>Something is wrong here</h2>
<p>These are simply benchmarks and are not meant to represent real world scenarios for a few reasons.&#160; Most importantly, this test takes place on a local network that goes through one router.&#160; Running this test on a local network does not take into consideration the typical network latency you would find across the internet.</p>
<p>Secondly, this test only illustrates the raw speed of serving up cached content which isn’t a typical real world scenario.&#160; To really test the overall performance of both of these, we need to simulate the three major steps of a reverse proxy: </p>
<ol>
<li>Forwarding a request to a backend server</li>
<li>Physically caching it (memory or disk)</li>
<li>Serving the cached data</li>
</ol>
<p>Testing any of these three steps is good, and shows the raw performance of that function but it doesn’t give us a general overview of the overall performance.</p>
<p>&#160;</p>
<h2>Next Steps</h2>
<p>I need to come up with a way to generate load on the server such that it represents the typical flow of requests that we would normally see on a server.&#160; I am running this on a test server, not against production data, so if anyone has an idea of how I can do this, please do let me know.&#160; The results of this test will be Part 2 of this post.</p>
<p>Additionally, please let me know if you spot inefficiencies in my testing methodology. I don’t claim to be a load testing expert so any advice you can offer is appreciated.</p>
<p>
				<table cellspacing="0" cellpadding="0" border="0" style="width: 300px; height: 50px; text-align: left; margin-left: auto; margin-right: auto;">
				<tbody>
				<tr>
				<td style="text-align: center;">
				<a href="http://del.icio.us/post?url=http://deserialized.com/reverse-proxy-performance-varnish-vs-squid-part-1/&title=Reverse Proxy Performance &ndash; Varnish vs. Squid (Part 1)" rel="nofollow">
				<img src="http://deserialized.com/wp-content/plugins/addtothis/delicious.png" alt="Add to Del.cio.us" style="border: 0px solid ; width: 48px; height: 48px;"/>
				</a>
				</td>
				<td style="text-align: center;">
				<a href="http://deserialized.com/feed/rss/" rel="nofollow">
				<img src="http://deserialized.com/wp-content/plugins/addtothis/feeds.png" alt="RSS Feed" style="border: 0px solid ; width: 48px; height: 48px;"/>
				</a>
				</td>
				<td style="text-align: center;">
				<a href="http://technorati.com/faves?add=http://deserialized.com/reverse-proxy-performance-varnish-vs-squid-part-1/" rel="nofollow">
				<img src="http://deserialized.com/wp-content/plugins/addtothis/technorati.png" alt="Add to Technorati Favorites" style="border: 0px solid ; width: 48px; height: 48px;"/>
				</a>
				</td>
				<td style="text-align: center;">
				<a href="http://www.stumbleupon.com/submit?url=http://deserialized.com/reverse-proxy-performance-varnish-vs-squid-part-1/&title=Reverse Proxy Performance &ndash; Varnish vs. Squid (Part 1)" rel="nofollow">
				<img src="http://deserialized.com/wp-content/plugins/addtothis/stumble.png" alt="Stumble It!" style="border: 0px solid ; width: 48px; height: 48px;"/>
				</a>
				
				</td>
				<td style="text-align: center;">
				<a href="http://digg.com/submit?phase=2&url=http://deserialized.com/reverse-proxy-performance-varnish-vs-squid-part-1/" rel="nofollow">
				<img src="http://deserialized.com/wp-content/plugins/addtothis/digg.png" alt="Digg It!" style="border: 0px solid ; width: 48px; height: 48px;"/>
				</a>
				
				</td>
				</tr>
				<tr><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td style="text-align: right;" ><a href="http://www.sajithmr.com"><img style="border:none" src="http://deserialized.com/wp-content/plugins/addtothis/sajithmr.png"  title="Powered By Sajithmr.com" alt="www.sajithmr.com"/></a></td></tr>
				</tbody>
				</table>

                
		
				</p>]]></content:encoded>
			<wfw:commentRss>http://deserialized.com/reverse-proxy-performance-varnish-vs-squid-part-1/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Some thoughts on string concatenation in C#</title>
		<link>http://deserialized.com/some-thoughts-on-string-concatenation-in-csharp/</link>
		<comments>http://deserialized.com/some-thoughts-on-string-concatenation-in-csharp/#comments</comments>
		<pubDate>Thu, 20 Aug 2009 20:54:19 +0000</pubDate>
		<dc:creator>Bryan Migliorisi</dc:creator>
				<category><![CDATA[C#]]></category>

		<guid isPermaLink="false">http://deserialized.com/?p=28</guid>
		<description><![CDATA[I recently stumbled into a blog entry on CodeProject.com that stated some things about string concatenation in C# that went against what I thought to be true, and it got me thinking. From the article: string sentence = &#34;The &#34; + &#34;dog &#34; + &#34;ate &#34; + &#34;the &#34; + &#34;cat &#34; + &#34;all &#34; [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fdeserialized.com%2Fsome-thoughts-on-string-concatenation-in-csharp%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fdeserialized.com%2Fsome-thoughts-on-string-concatenation-in-csharp%2F&amp;source=BryanMigliorisi&amp;style=normal&amp;service=is.gd" height="61" width="50" /><br />
			</a>
		</div>
<p>I recently stumbled into a <a href="http://www.codeproject.com/KB/string/StringBuilderPlus.aspx">blog entry on CodeProject.com</a> that stated some things about string concatenation in C# that went against what I thought to be true, and it got me thinking.</p>
<p>From the article:</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #FF0000;">string</span> sentence <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;The &quot;</span> <span style="color: #008000;">+</span> <span style="color: #666666;">&quot;dog &quot;</span> <span style="color: #008000;">+</span> <span style="color: #666666;">&quot;ate &quot;</span> <span style="color: #008000;">+</span> <span style="color: #666666;">&quot;the &quot;</span> <span style="color: #008000;">+</span> <span style="color: #666666;">&quot;cat &quot;</span> <span style="color: #008000;">+</span> <span style="color: #666666;">&quot;all &quot;</span> <span style="color: #008000;">+</span> <span style="color: #666666;">&quot;day &quot;</span> <span style="color: #008000;">+</span> <span style="color: #666666;">&quot;for &quot;</span> <span style="color: #008000;">+</span> <span style="color: #666666;">&quot;for &quot;</span> <span style="color: #008000;">+</span> <span style="color: #666666;">&quot;fun.&quot;</span><span style="color: #008000;">;</span></pre></div></div>

<p>”That innocent looking line of code actually takes up much more processing power and memory than it appears to. If strings were combined in the ideal way, you would expect that the sentence would be the only string created from this operation. However, since each string is combined to its neighbor in succession, it turns out that 7 other strings are also created (shown in gray in the diagram above). The total amount of unnecessary memory allocations created from this operation is equal to the following equation, where N is the number of strings you are combining…”</p>
<p>But I knew that couldn’t be true, so I fired up Visual Studio and wrote a few simple tests, compiled and then analyzed the generated <a href="http://en.wikipedia.org/wiki/Common_Intermediate_Language">CIL</a>.</p>
<p><strong>First test:</strong></p>
<p>Original C#:</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF;">public</span> <span style="color: #FF0000;">string</span> createStringOne<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
    <span style="color: #0600FF;">return</span> <span style="color: #666666;">&quot;The &quot;</span> <span style="color: #008000;">+</span> <span style="color: #666666;">&quot;dog &quot;</span> <span style="color: #008000;">+</span> <span style="color: #666666;">&quot;ate &quot;</span> <span style="color: #008000;">+</span> <span style="color: #666666;">&quot;the &quot;</span> <span style="color: #008000;">+</span> <span style="color: #666666;">&quot;cat &quot;</span> <span style="color: #008000;">+</span> <span style="color: #666666;">&quot;all &quot;</span> <span style="color: #008000;">+</span> <span style="color: #666666;">&quot;day &quot;</span> <span style="color: #008000;">+</span> <span style="color: #666666;">&quot;for &quot;</span> <span style="color: #008000;">+</span> <span style="color: #666666;">&quot;for &quot;</span> <span style="color: #008000;">+</span> <span style="color: #666666;">&quot;fun.&quot;</span><span style="color: #008000;">;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

<p>Generated CIL:</p>

<div class="wp_syntax"><div class="code"><pre class="cil" style="font-family:monospace;"><span style="color:maroon;font-weight:bold;">.method</span> <span style="color:blue;font-weight:bold;">public</span> <span style="color:blue;font-weight:bold;">hidebysig</span> <span style="color:blue;font-weight:bold;">instance</span> <span style="color:purple;font-weight:bold;">string</span> createStringOne<span style="color: #006400;">&#40;</span><span style="color: #006400;">&#41;</span> <span style="color:blue;font-weight:bold;">cil</span> <span style="color:blue;font-weight:bold;">managed</span>
<span style="color: #006400;">&#123;</span>
    <span style="color:maroon;font-weight:bold;">.maxstack</span> <span style="color: #00008B;">8</span>
    L_0000: <span style="color:blue;">ldstr</span> <span style="color: #008000;">&quot;The dog ate the cat all day for for fun.&quot;</span>
    L_0005: <span style="color:blue;">ret</span>
<span style="color: #006400;">&#125;</span></pre></div></div>

<p><strong>Second test:</strong></p>
<p>Original C#:</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF;">public</span> <span style="color: #FF0000;">string</span> createStringTwo<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
    <span style="color: #0600FF;">return</span> <span style="color: #666666;">&quot;The dog ate the cat all day for for fun.&quot;</span><span style="color: #008000;">;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

<p>Generated CIL:</p>

<div class="wp_syntax"><div class="code"><pre class="cil" style="font-family:monospace;"><span style="color:maroon;font-weight:bold;">.method</span> <span style="color:blue;font-weight:bold;">public</span> <span style="color:blue;font-weight:bold;">hidebysig</span> <span style="color:blue;font-weight:bold;">instance</span> <span style="color:purple;font-weight:bold;">string</span> createStringTwo<span style="color: #006400;">&#40;</span><span style="color: #006400;">&#41;</span> <span style="color:blue;font-weight:bold;">cil</span> <span style="color:blue;font-weight:bold;">managed</span>
<span style="color: #006400;">&#123;</span>
    <span style="color:maroon;font-weight:bold;">.maxstack</span> <span style="color: #00008B;">8</span>
    L_0000: <span style="color:blue;">ldstr</span> <span style="color: #008000;">&quot;The dog ate the cat all day for for fun.&quot;</span>
    L_0005: <span style="color:blue;">ret</span>
<span style="color: #006400;">&#125;</span></pre></div></div>

<p><strong>Third test:</strong></p>
<p>Original C#:</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF;">public</span> <span style="color: #FF0000;">string</span> createStringThree<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
    var sb <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> StringBuilder<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
    sb.<span style="color: #0000FF;">Append</span><span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;The &quot;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
    sb.<span style="color: #0000FF;">Append</span><span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;dog &quot;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
    sb.<span style="color: #0000FF;">Append</span><span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;ate &quot;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
    sb.<span style="color: #0000FF;">Append</span><span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;the &quot;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
    sb.<span style="color: #0000FF;">Append</span><span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;cat &quot;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
    sb.<span style="color: #0000FF;">Append</span><span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;all &quot;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
    sb.<span style="color: #0000FF;">Append</span><span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;day &quot;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
    sb.<span style="color: #0000FF;">Append</span><span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;for &quot;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
    sb.<span style="color: #0000FF;">Append</span><span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;for &quot;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
    sb.<span style="color: #0000FF;">Append</span><span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;fun.&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
    <span style="color: #0600FF;">return</span> sb.<span style="color: #0000FF;">ToString</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

<p>Generated CIL:</p>

<div class="wp_syntax"><div class="code"><pre class="cil" style="font-family:monospace;"><span style="color:maroon;font-weight:bold;">.method</span> <span style="color:blue;font-weight:bold;">public</span> <span style="color:blue;font-weight:bold;">hidebysig</span> <span style="color:blue;font-weight:bold;">instance</span> <span style="color:purple;font-weight:bold;">string</span> createStringThree<span style="color: #006400;">&#40;</span><span style="color: #006400;">&#41;</span> <span style="color:blue;font-weight:bold;">cil</span> <span style="color:blue;font-weight:bold;">managed</span>
<span style="color: #006400;">&#123;</span>
    <span style="color:maroon;font-weight:bold;">.maxstack</span> <span style="color: #00008B;">2</span>
    <span style="color:maroon;font-weight:bold;">.locals</span> <span style="color:blue;font-weight:bold;">init</span> <span style="color: #006400;">&#40;</span>
        <span style="color: #006400;">&#91;</span><span style="color: #00008B;">0</span><span style="color: #006400;">&#93;</span> <span style="color:blue;font-weight:bold;">class</span> <span style="color: #006400;">&#91;</span>mscorlib<span style="color: #006400;">&#93;</span>System.Text.StringBuilder sb<span style="color: #006400;">&#41;</span>
    L_0000: <span style="color:blue;">newobj</span> <span style="color:blue;font-weight:bold;">instance</span> <span style="color:purple;font-weight:bold;">void</span> <span style="color: #006400;">&#91;</span>mscorlib<span style="color: #006400;">&#93;</span>System.Text.StringBuilder::<span style="color:maroon;font-weight:bold;">.ctor</span><span style="color: #006400;">&#40;</span><span style="color: #006400;">&#41;</span>
    L_0005: <span style="color:blue;">stloc</span>.<span style="color:blue;">0</span>
    L_0006: <span style="color:blue;">ldloc</span>.<span style="color:blue;">0</span>
    L_0007: <span style="color:blue;">ldstr</span> <span style="color: #008000;">&quot;The &quot;</span>
    L_000c: <span style="color:blue;">callvirt</span> <span style="color:blue;font-weight:bold;">instance</span> <span style="color:blue;font-weight:bold;">class</span> <span style="color: #006400;">&#91;</span>mscorlib<span style="color: #006400;">&#93;</span>System.Text.StringBuilder <span style="color: #006400;">&#91;</span>mscorlib<span style="color: #006400;">&#93;</span>System.Text.StringBuilder::<span style="color: #000033;">Append</span><span style="color: #006400;">&#40;</span><span style="color:purple;font-weight:bold;">string</span><span style="color: #006400;">&#41;</span>
    L_0011: <span style="color:blue;">pop</span>
    L_0012: <span style="color:blue;">ldloc</span>.<span style="color:blue;">0</span>
    L_0013: <span style="color:blue;">ldstr</span> <span style="color: #008000;">&quot;dog &quot;</span>
    L_0018: <span style="color:blue;">callvirt</span> <span style="color:blue;font-weight:bold;">instance</span> <span style="color:blue;font-weight:bold;">class</span> <span style="color: #006400;">&#91;</span>mscorlib<span style="color: #006400;">&#93;</span>System.Text.StringBuilder <span style="color: #006400;">&#91;</span>mscorlib<span style="color: #006400;">&#93;</span>System.Text.StringBuilder::<span style="color: #000033;">Append</span><span style="color: #006400;">&#40;</span><span style="color:purple;font-weight:bold;">string</span><span style="color: #006400;">&#41;</span>
    L_001d: <span style="color:blue;">pop</span>
    L_001e: <span style="color:blue;">ldloc</span>.<span style="color:blue;">0</span>
    L_001f: <span style="color:blue;">ldstr</span> <span style="color: #008000;">&quot;ate &quot;</span>
    L_0024: <span style="color:blue;">callvirt</span> <span style="color:blue;font-weight:bold;">instance</span> <span style="color:blue;font-weight:bold;">class</span> <span style="color: #006400;">&#91;</span>mscorlib<span style="color: #006400;">&#93;</span>System.Text.StringBuilder <span style="color: #006400;">&#91;</span>mscorlib<span style="color: #006400;">&#93;</span>System.Text.StringBuilder::<span style="color: #000033;">Append</span><span style="color: #006400;">&#40;</span><span style="color:purple;font-weight:bold;">string</span><span style="color: #006400;">&#41;</span>
    L_0029: <span style="color:blue;">pop</span>
    L_002a: <span style="color:blue;">ldloc</span>.<span style="color:blue;">0</span>
    L_002b: <span style="color:blue;">ldstr</span> <span style="color: #008000;">&quot;the &quot;</span>
    L_0030: <span style="color:blue;">callvirt</span> <span style="color:blue;font-weight:bold;">instance</span> <span style="color:blue;font-weight:bold;">class</span> <span style="color: #006400;">&#91;</span>mscorlib<span style="color: #006400;">&#93;</span>System.Text.StringBuilder <span style="color: #006400;">&#91;</span>mscorlib<span style="color: #006400;">&#93;</span>System.Text.StringBuilder::<span style="color: #000033;">Append</span><span style="color: #006400;">&#40;</span><span style="color:purple;font-weight:bold;">string</span><span style="color: #006400;">&#41;</span>
    L_0035: <span style="color:blue;">pop</span>
    L_0036: <span style="color:blue;">ldloc</span>.<span style="color:blue;">0</span>
    L_0037: <span style="color:blue;">ldstr</span> <span style="color: #008000;">&quot;cat &quot;</span>
    L_003c: <span style="color:blue;">callvirt</span> <span style="color:blue;font-weight:bold;">instance</span> <span style="color:blue;font-weight:bold;">class</span> <span style="color: #006400;">&#91;</span>mscorlib<span style="color: #006400;">&#93;</span>System.Text.StringBuilder <span style="color: #006400;">&#91;</span>mscorlib<span style="color: #006400;">&#93;</span>System.Text.StringBuilder::<span style="color: #000033;">Append</span><span style="color: #006400;">&#40;</span><span style="color:purple;font-weight:bold;">string</span><span style="color: #006400;">&#41;</span>
    L_0041: <span style="color:blue;">pop</span>
    L_0042: <span style="color:blue;">ldloc</span>.<span style="color:blue;">0</span>
    L_0043: <span style="color:blue;">ldstr</span> <span style="color: #008000;">&quot;all &quot;</span>
    L_0048: <span style="color:blue;">callvirt</span> <span style="color:blue;font-weight:bold;">instance</span> <span style="color:blue;font-weight:bold;">class</span> <span style="color: #006400;">&#91;</span>mscorlib<span style="color: #006400;">&#93;</span>System.Text.StringBuilder <span style="color: #006400;">&#91;</span>mscorlib<span style="color: #006400;">&#93;</span>System.Text.StringBuilder::<span style="color: #000033;">Append</span><span style="color: #006400;">&#40;</span><span style="color:purple;font-weight:bold;">string</span><span style="color: #006400;">&#41;</span>
    L_004d: <span style="color:blue;">pop</span>
    L_004e: <span style="color:blue;">ldloc</span>.<span style="color:blue;">0</span>
    L_004f: <span style="color:blue;">ldstr</span> <span style="color: #008000;">&quot;day &quot;</span>
    L_0054: <span style="color:blue;">callvirt</span> <span style="color:blue;font-weight:bold;">instance</span> <span style="color:blue;font-weight:bold;">class</span> <span style="color: #006400;">&#91;</span>mscorlib<span style="color: #006400;">&#93;</span>System.Text.StringBuilder <span style="color: #006400;">&#91;</span>mscorlib<span style="color: #006400;">&#93;</span>System.Text.StringBuilder::<span style="color: #000033;">Append</span><span style="color: #006400;">&#40;</span><span style="color:purple;font-weight:bold;">string</span><span style="color: #006400;">&#41;</span>
    L_0059: <span style="color:blue;">pop</span>
    L_005a: <span style="color:blue;">ldloc</span>.<span style="color:blue;">0</span>
    L_005b: <span style="color:blue;">ldstr</span> <span style="color: #008000;">&quot;for &quot;</span>
    L_0060: <span style="color:blue;">callvirt</span> <span style="color:blue;font-weight:bold;">instance</span> <span style="color:blue;font-weight:bold;">class</span> <span style="color: #006400;">&#91;</span>mscorlib<span style="color: #006400;">&#93;</span>System.Text.StringBuilder <span style="color: #006400;">&#91;</span>mscorlib<span style="color: #006400;">&#93;</span>System.Text.StringBuilder::<span style="color: #000033;">Append</span><span style="color: #006400;">&#40;</span><span style="color:purple;font-weight:bold;">string</span><span style="color: #006400;">&#41;</span>
    L_0065: <span style="color:blue;">pop</span>
    L_0066: <span style="color:blue;">ldloc</span>.<span style="color:blue;">0</span>
    L_0067: <span style="color:blue;">ldstr</span> <span style="color: #008000;">&quot;for &quot;</span>
    L_006c: <span style="color:blue;">callvirt</span> <span style="color:blue;font-weight:bold;">instance</span> <span style="color:blue;font-weight:bold;">class</span> <span style="color: #006400;">&#91;</span>mscorlib<span style="color: #006400;">&#93;</span>System.Text.StringBuilder <span style="color: #006400;">&#91;</span>mscorlib<span style="color: #006400;">&#93;</span>System.Text.StringBuilder::<span style="color: #000033;">Append</span><span style="color: #006400;">&#40;</span><span style="color:purple;font-weight:bold;">string</span><span style="color: #006400;">&#41;</span>
    L_0071: <span style="color:blue;">pop</span>
    L_0072: <span style="color:blue;">ldloc</span>.<span style="color:blue;">0</span>
    L_0073: <span style="color:blue;">ldstr</span> <span style="color: #008000;">&quot;fun.&quot;</span>
    L_0078: <span style="color:blue;">callvirt</span> <span style="color:blue;font-weight:bold;">instance</span> <span style="color:blue;font-weight:bold;">class</span> <span style="color: #006400;">&#91;</span>mscorlib<span style="color: #006400;">&#93;</span>System.Text.StringBuilder <span style="color: #006400;">&#91;</span>mscorlib<span style="color: #006400;">&#93;</span>System.Text.StringBuilder::<span style="color: #000033;">Append</span><span style="color: #006400;">&#40;</span><span style="color:purple;font-weight:bold;">string</span><span style="color: #006400;">&#41;</span>
    L_007d: <span style="color:blue;">pop</span>
    L_007e: <span style="color:blue;">ldloc</span>.<span style="color:blue;">0</span>
    L_007f: <span style="color:blue;">callvirt</span> <span style="color:blue;font-weight:bold;">instance</span> <span style="color:purple;font-weight:bold;">string</span> <span style="color: #006400;">&#91;</span>mscorlib<span style="color: #006400;">&#93;</span>System.Object::<span style="color: #000033;">ToString</span><span style="color: #006400;">&#40;</span><span style="color: #006400;">&#41;</span>
    L_0084: <span style="color:blue;">ret</span>
<span style="color: #006400;">&#125;</span></pre></div></div>

<p><strong>Fourth test:</strong></p>
<p>Original C#:</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF;">public</span> <span style="color: #FF0000;">string</span> createStringFour<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
    <span style="color: #0600FF;">return</span> <span style="color: #008000;">new</span> StringBuilder<span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;The dog ate the cat all day for for fun.&quot;</span><span style="color: #000000;">&#41;</span>.<span style="color: #0000FF;">ToString</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

<p>Generated CIL:</p>

<div class="wp_syntax"><div class="code"><pre class="cil" style="font-family:monospace;"><span style="color:maroon;font-weight:bold;">.method</span> <span style="color:blue;font-weight:bold;">public</span> <span style="color:blue;font-weight:bold;">hidebysig</span> <span style="color:blue;font-weight:bold;">instance</span> <span style="color:purple;font-weight:bold;">string</span> createStringFour<span style="color: #006400;">&#40;</span><span style="color: #006400;">&#41;</span> <span style="color:blue;font-weight:bold;">cil</span> <span style="color:blue;font-weight:bold;">managed</span>
<span style="color: #006400;">&#123;</span>
    <span style="color:maroon;font-weight:bold;">.maxstack</span> <span style="color: #00008B;">8</span>
    L_0000: <span style="color:blue;">ldstr</span> <span style="color: #008000;">&quot;The dog ate the cat all day for for fun.&quot;</span>
    L_0005: <span style="color:blue;">newobj</span> <span style="color:blue;font-weight:bold;">instance</span> <span style="color:purple;font-weight:bold;">void</span> <span style="color: #006400;">&#91;</span>mscorlib<span style="color: #006400;">&#93;</span>System.Text.StringBuilder::<span style="color:maroon;font-weight:bold;">.ctor</span><span style="color: #006400;">&#40;</span><span style="color:purple;font-weight:bold;">string</span><span style="color: #006400;">&#41;</span>
    L_000a: <span style="color:blue;">callvirt</span> <span style="color:blue;font-weight:bold;">instance</span> <span style="color:purple;font-weight:bold;">string</span> <span style="color: #006400;">&#91;</span>mscorlib<span style="color: #006400;">&#93;</span>System.Object::<span style="color: #000033;">ToString</span><span style="color: #006400;">&#40;</span><span style="color: #006400;">&#41;</span>
    L_000f: <span style="color:blue;">ret</span>
<span style="color: #006400;">&#125;</span></pre></div></div>

<p><strong>Fifth test:</strong></p>
<p>Original C#:</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF;">public</span> <span style="color: #FF0000;">string</span> createStringFive<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
    <span style="color: #FF0000;">string</span> s <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;The &quot;</span><span style="color: #008000;">;</span>
    s <span style="color: #008000;">+=</span> <span style="color: #666666;">&quot;dog &quot;</span><span style="color: #008000;">;</span>
    s <span style="color: #008000;">+=</span> <span style="color: #666666;">&quot;ate &quot;</span><span style="color: #008000;">;</span>
    s <span style="color: #008000;">+=</span> <span style="color: #666666;">&quot;the &quot;</span><span style="color: #008000;">;</span>
    s <span style="color: #008000;">+=</span> <span style="color: #666666;">&quot;cat &quot;</span><span style="color: #008000;">;</span>
    s <span style="color: #008000;">+=</span> <span style="color: #666666;">&quot;all &quot;</span><span style="color: #008000;">;</span>
    s <span style="color: #008000;">+=</span> <span style="color: #666666;">&quot;day &quot;</span><span style="color: #008000;">;</span>
    s <span style="color: #008000;">+=</span> <span style="color: #666666;">&quot;for &quot;</span><span style="color: #008000;">;</span>
    s <span style="color: #008000;">+=</span> <span style="color: #666666;">&quot;for &quot;</span><span style="color: #008000;">;</span>
    s <span style="color: #008000;">+=</span> <span style="color: #666666;">&quot;fun.&quot;</span><span style="color: #008000;">;</span>
    <span style="color: #0600FF;">return</span> s<span style="color: #008000;">;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

<p>Generated CIL:</p>

<div class="wp_syntax"><div class="code"><pre class="cil" style="font-family:monospace;"><span style="color:maroon;font-weight:bold;">.method</span> <span style="color:blue;font-weight:bold;">public</span> <span style="color:blue;font-weight:bold;">hidebysig</span> <span style="color:blue;font-weight:bold;">instance</span> <span style="color:purple;font-weight:bold;">string</span> createStringFive<span style="color: #006400;">&#40;</span><span style="color: #006400;">&#41;</span> <span style="color:blue;font-weight:bold;">cil</span> <span style="color:blue;font-weight:bold;">managed</span>
<span style="color: #006400;">&#123;</span>
    <span style="color:maroon;font-weight:bold;">.maxstack</span> <span style="color: #00008B;">2</span>
    <span style="color:maroon;font-weight:bold;">.locals</span> <span style="color:blue;font-weight:bold;">init</span> <span style="color: #006400;">&#40;</span>
        <span style="color: #006400;">&#91;</span><span style="color: #00008B;">0</span><span style="color: #006400;">&#93;</span> <span style="color:purple;font-weight:bold;">string</span> <span style="color:blue;">s</span><span style="color: #006400;">&#41;</span>
    L_0000: <span style="color:blue;">ldstr</span> <span style="color: #008000;">&quot;The &quot;</span>
    L_0005: <span style="color:blue;">stloc</span>.<span style="color:blue;">0</span>
    L_0006: <span style="color:blue;">ldloc</span>.<span style="color:blue;">0</span>
    L_0007: <span style="color:blue;">ldstr</span> <span style="color: #008000;">&quot;dog &quot;</span>
    L_000c: <span style="color:blue;">call</span> <span style="color:purple;font-weight:bold;">string</span> <span style="color: #006400;">&#91;</span>mscorlib<span style="color: #006400;">&#93;</span>System.String::<span style="color: #000033;">Concat</span><span style="color: #006400;">&#40;</span><span style="color:purple;font-weight:bold;">string</span>, <span style="color:purple;font-weight:bold;">string</span><span style="color: #006400;">&#41;</span>
    L_0011: <span style="color:blue;">stloc</span>.<span style="color:blue;">0</span>
    L_0012: <span style="color:blue;">ldloc</span>.<span style="color:blue;">0</span>
    L_0013: <span style="color:blue;">ldstr</span> <span style="color: #008000;">&quot;ate &quot;</span>
    L_0018: <span style="color:blue;">call</span> <span style="color:purple;font-weight:bold;">string</span> <span style="color: #006400;">&#91;</span>mscorlib<span style="color: #006400;">&#93;</span>System.String::<span style="color: #000033;">Concat</span><span style="color: #006400;">&#40;</span><span style="color:purple;font-weight:bold;">string</span>, <span style="color:purple;font-weight:bold;">string</span><span style="color: #006400;">&#41;</span>
    L_001d: <span style="color:blue;">stloc</span>.<span style="color:blue;">0</span>
    L_001e: <span style="color:blue;">ldloc</span>.<span style="color:blue;">0</span>
    L_001f: <span style="color:blue;">ldstr</span> <span style="color: #008000;">&quot;the &quot;</span>
    L_0024: <span style="color:blue;">call</span> <span style="color:purple;font-weight:bold;">string</span> <span style="color: #006400;">&#91;</span>mscorlib<span style="color: #006400;">&#93;</span>System.String::<span style="color: #000033;">Concat</span><span style="color: #006400;">&#40;</span><span style="color:purple;font-weight:bold;">string</span>, <span style="color:purple;font-weight:bold;">string</span><span style="color: #006400;">&#41;</span>
    L_0029: <span style="color:blue;">stloc</span>.<span style="color:blue;">0</span>
    L_002a: <span style="color:blue;">ldloc</span>.<span style="color:blue;">0</span>
    L_002b: <span style="color:blue;">ldstr</span> <span style="color: #008000;">&quot;cat &quot;</span>
    L_0030: <span style="color:blue;">call</span> <span style="color:purple;font-weight:bold;">string</span> <span style="color: #006400;">&#91;</span>mscorlib<span style="color: #006400;">&#93;</span>System.String::<span style="color: #000033;">Concat</span><span style="color: #006400;">&#40;</span><span style="color:purple;font-weight:bold;">string</span>, <span style="color:purple;font-weight:bold;">string</span><span style="color: #006400;">&#41;</span>
    L_0035: <span style="color:blue;">stloc</span>.<span style="color:blue;">0</span>
    L_0036: <span style="color:blue;">ldloc</span>.<span style="color:blue;">0</span>
    L_0037: <span style="color:blue;">ldstr</span> <span style="color: #008000;">&quot;all &quot;</span>
    L_003c: <span style="color:blue;">call</span> <span style="color:purple;font-weight:bold;">string</span> <span style="color: #006400;">&#91;</span>mscorlib<span style="color: #006400;">&#93;</span>System.String::<span style="color: #000033;">Concat</span><span style="color: #006400;">&#40;</span><span style="color:purple;font-weight:bold;">string</span>, <span style="color:purple;font-weight:bold;">string</span><span style="color: #006400;">&#41;</span>
    L_0041: <span style="color:blue;">stloc</span>.<span style="color:blue;">0</span>
    L_0042: <span style="color:blue;">ldloc</span>.<span style="color:blue;">0</span>
    L_0043: <span style="color:blue;">ldstr</span> <span style="color: #008000;">&quot;day &quot;</span>
    L_0048: <span style="color:blue;">call</span> <span style="color:purple;font-weight:bold;">string</span> <span style="color: #006400;">&#91;</span>mscorlib<span style="color: #006400;">&#93;</span>System.String::<span style="color: #000033;">Concat</span><span style="color: #006400;">&#40;</span><span style="color:purple;font-weight:bold;">string</span>, <span style="color:purple;font-weight:bold;">string</span><span style="color: #006400;">&#41;</span>
    L_004d: <span style="color:blue;">stloc</span>.<span style="color:blue;">0</span>
    L_004e: <span style="color:blue;">ldloc</span>.<span style="color:blue;">0</span>
    L_004f: <span style="color:blue;">ldstr</span> <span style="color: #008000;">&quot;for &quot;</span>
    L_0054: <span style="color:blue;">call</span> <span style="color:purple;font-weight:bold;">string</span> <span style="color: #006400;">&#91;</span>mscorlib<span style="color: #006400;">&#93;</span>System.String::<span style="color: #000033;">Concat</span><span style="color: #006400;">&#40;</span><span style="color:purple;font-weight:bold;">string</span>, <span style="color:purple;font-weight:bold;">string</span><span style="color: #006400;">&#41;</span>
    L_0059: <span style="color:blue;">stloc</span>.<span style="color:blue;">0</span>
    L_005a: <span style="color:blue;">ldloc</span>.<span style="color:blue;">0</span>
    L_005b: <span style="color:blue;">ldstr</span> <span style="color: #008000;">&quot;for &quot;</span>
    L_0060: <span style="color:blue;">call</span> <span style="color:purple;font-weight:bold;">string</span> <span style="color: #006400;">&#91;</span>mscorlib<span style="color: #006400;">&#93;</span>System.String::<span style="color: #000033;">Concat</span><span style="color: #006400;">&#40;</span><span style="color:purple;font-weight:bold;">string</span>, <span style="color:purple;font-weight:bold;">string</span><span style="color: #006400;">&#41;</span>
    L_0065: <span style="color:blue;">stloc</span>.<span style="color:blue;">0</span>
    L_0066: <span style="color:blue;">ldloc</span>.<span style="color:blue;">0</span>
    L_0067: <span style="color:blue;">ldstr</span> <span style="color: #008000;">&quot;fun.&quot;</span>
    L_006c: <span style="color:blue;">call</span> <span style="color:purple;font-weight:bold;">string</span> <span style="color: #006400;">&#91;</span>mscorlib<span style="color: #006400;">&#93;</span>System.String::<span style="color: #000033;">Concat</span><span style="color: #006400;">&#40;</span><span style="color:purple;font-weight:bold;">string</span>, <span style="color:purple;font-weight:bold;">string</span><span style="color: #006400;">&#41;</span>
    L_0071: <span style="color:blue;">stloc</span>.<span style="color:blue;">0</span>
    L_0072: <span style="color:blue;">ldloc</span>.<span style="color:blue;">0</span>
    L_0073: <span style="color:blue;">ret</span>
<span style="color: #006400;">&#125;</span></pre></div></div>

<p><strong>Results:</strong></p>
<p>So as you can see, the first two methods are essentially the same thing!  It doesn&#8217;t matter if we concatenate one large string from several smaller strings if (and only if) it happens on one operation.  If concatenation is done using multiple operations, then it does in fact incur a performance and memory hit.</p>
<p>The use of a StringBuilder in this case (where there are only a small handful of small strings) serves no purpose as far as performance is concerned.</p>
<p><strong> </strong></p>
<p><strong>But… how are they equal!?</strong></p>
<p>Compiler optimizations!  The C# compiler is an incredible piece of software that can look at your code and “fix” it.  It is important when working on code optimizations like the one in the article mentioned above that developers take into consideration compiler optimizations that may alter the code that they think is poorly written.</p>
<p>
				<table cellspacing="0" cellpadding="0" border="0" style="width: 300px; height: 50px; text-align: left; margin-left: auto; margin-right: auto;">
				<tbody>
				<tr>
				<td style="text-align: center;">
				<a href="http://del.icio.us/post?url=http://deserialized.com/some-thoughts-on-string-concatenation-in-csharp/&title=Some thoughts on string concatenation in C#" rel="nofollow">
				<img src="http://deserialized.com/wp-content/plugins/addtothis/delicious.png" alt="Add to Del.cio.us" style="border: 0px solid ; width: 48px; height: 48px;"/>
				</a>
				</td>
				<td style="text-align: center;">
				<a href="http://deserialized.com/feed/rss/" rel="nofollow">
				<img src="http://deserialized.com/wp-content/plugins/addtothis/feeds.png" alt="RSS Feed" style="border: 0px solid ; width: 48px; height: 48px;"/>
				</a>
				</td>
				<td style="text-align: center;">
				<a href="http://technorati.com/faves?add=http://deserialized.com/some-thoughts-on-string-concatenation-in-csharp/" rel="nofollow">
				<img src="http://deserialized.com/wp-content/plugins/addtothis/technorati.png" alt="Add to Technorati Favorites" style="border: 0px solid ; width: 48px; height: 48px;"/>
				</a>
				</td>
				<td style="text-align: center;">
				<a href="http://www.stumbleupon.com/submit?url=http://deserialized.com/some-thoughts-on-string-concatenation-in-csharp/&title=Some thoughts on string concatenation in C#" rel="nofollow">
				<img src="http://deserialized.com/wp-content/plugins/addtothis/stumble.png" alt="Stumble It!" style="border: 0px solid ; width: 48px; height: 48px;"/>
				</a>
				
				</td>
				<td style="text-align: center;">
				<a href="http://digg.com/submit?phase=2&url=http://deserialized.com/some-thoughts-on-string-concatenation-in-csharp/" rel="nofollow">
				<img src="http://deserialized.com/wp-content/plugins/addtothis/digg.png" alt="Digg It!" style="border: 0px solid ; width: 48px; height: 48px;"/>
				</a>
				
				</td>
				</tr>
				<tr><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td style="text-align: right;" ><a href="http://www.sajithmr.com"><img style="border:none" src="http://deserialized.com/wp-content/plugins/addtothis/sajithmr.png"  title="Powered By Sajithmr.com" alt="www.sajithmr.com"/></a></td></tr>
				</tbody>
				</table>

                
		
				</p>]]></content:encoded>
			<wfw:commentRss>http://deserialized.com/some-thoughts-on-string-concatenation-in-csharp/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Comparing while() loops with for() loops in C#</title>
		<link>http://deserialized.com/comparing-while-loops-with-for-loops-in-c/</link>
		<comments>http://deserialized.com/comparing-while-loops-with-for-loops-in-c/#comments</comments>
		<pubDate>Wed, 19 Aug 2009 17:20:23 +0000</pubDate>
		<dc:creator>Bryan Migliorisi</dc:creator>
				<category><![CDATA[C#]]></category>

		<guid isPermaLink="false">http://deserialized.com/?p=21</guid>
		<description><![CDATA[There is always a lot of debate about the speed and performance of loops in any language.&#160; I was curious to see what the differences were between a for() loop and a while() loop in C# and ultimately the .NET CLR. What I found was no big surprise to me, as it simply confirms what [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fdeserialized.com%2Fcomparing-while-loops-with-for-loops-in-c%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fdeserialized.com%2Fcomparing-while-loops-with-for-loops-in-c%2F&amp;source=BryanMigliorisi&amp;style=normal&amp;service=is.gd" height="61" width="50" /><br />
			</a>
		</div>
<p>There is always a lot of debate about the speed and performance of loops in any language.&#160; I was curious to see what the differences were between a for() loop and a while() loop in C# and ultimately the .NET CLR.</p>
<p>What I found was no big surprise to me, as it simply confirms what I have been reading for many years.&#160; While loops are simply faster and less complex than for loops.&#160; I did a very simple test to verify this.&#160; I created two loops that contained empty bodies.&#160; You can see them below:</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF;">public</span> <span style="color: #0600FF;">void</span> doFor<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
    <span style="color: #FF0000;">int</span> i <span style="color: #008000;">=</span> <span style="color: #FF0000;">0</span><span style="color: #008000;">;</span>
    <span style="color: #FF0000;">int</span> len <span style="color: #008000;">=</span> <span style="color: #FF0000;">100</span><span style="color: #008000;">;</span>
&nbsp;
    <span style="color: #0600FF;">for</span> <span style="color: #000000;">&#40;</span>i <span style="color: #008000;">=</span> <span style="color: #FF0000;">0</span><span style="color: #008000;">;</span> i <span style="color: #008000;">&amp;</span>lt<span style="color: #008000;">;</span> len<span style="color: #008000;">;</span> i<span style="color: #008000;">++</span><span style="color: #000000;">&#41;</span>
    <span style="color: #000000;">&#123;</span>
&nbsp;
    <span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF;">public</span> <span style="color: #0600FF;">void</span> doWhile<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
    <span style="color: #FF0000;">int</span> i <span style="color: #008000;">=</span> <span style="color: #FF0000;">100</span><span style="color: #008000;">;</span>
    <span style="color: #0600FF;">while</span> <span style="color: #000000;">&#40;</span>i<span style="color: #008000;">--</span> <span style="color: #008000;">==</span> <span style="color: #FF0000;">0</span><span style="color: #000000;">&#41;</span>
    <span style="color: #000000;">&#123;</span>
&nbsp;
    <span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

<p>&#160;</p>
<p>As you can see, both of these loops are as basic as they can be and have no inner bodies to complicate the <a href="http://en.wikipedia.org/wiki/Common_Intermediate_Language">CIL</a>.&#160; Lets take a look at the generated <a href="http://en.wikipedia.org/wiki/Common_Intermediate_Language">CIL</a> for each of them.</p>
<p>&#160;</p>
<p><strong>The generated <a href="http://en.wikipedia.org/wiki/Common_Intermediate_Language">CIL</a> for a for() loop</strong></p>

<div class="wp_syntax"><div class="code"><pre class="cil" style="font-family:monospace;"><span style="color:maroon;font-weight:bold;">.method</span> <span style="color:blue;font-weight:bold;">public</span> <span style="color:blue;font-weight:bold;">hidebysig</span> <span style="color:blue;font-weight:bold;">instance</span> <span style="color:purple;font-weight:bold;">void</span> doFor<span style="color: #006400;">&#40;</span><span style="color: #006400;">&#41;</span> <span style="color:blue;font-weight:bold;">cil</span> <span style="color:blue;font-weight:bold;">managed</span>
<span style="color: #006400;">&#123;</span>
    <span style="color:maroon;font-weight:bold;">.maxstack</span> <span style="color: #00008B;">2</span>
    <span style="color:maroon;font-weight:bold;">.locals</span> <span style="color:blue;font-weight:bold;">init</span> <span style="color: #006400;">&#40;</span>
        <span style="color: #006400;">&#91;</span><span style="color: #00008B;">0</span><span style="color: #006400;">&#93;</span> <span style="color:purple;font-weight:bold;">int32</span> <span style="color:blue;">i</span>,
        <span style="color: #006400;">&#91;</span><span style="color: #00008B;">1</span><span style="color: #006400;">&#93;</span> <span style="color:purple;font-weight:bold;">int32</span> len<span style="color: #006400;">&#41;</span>
    L_0000: <span style="color:blue;">ldc</span>.<span style="color:blue;">i4</span>.<span style="color:blue;">0</span> 
    L_0001: <span style="color:blue;">stloc</span>.<span style="color:blue;">0</span> 
    L_0002: <span style="color:blue;">ldc</span>.<span style="color:blue;">i4</span>.<span style="color:blue;">s</span> <span style="color: #00008B;">100</span>
    L_0004: <span style="color:blue;">stloc</span>.<span style="color:blue;">1</span> 
    L_0005: <span style="color:blue;">ldc</span>.<span style="color:blue;">i4</span>.<span style="color:blue;">0</span> 
    L_0006: <span style="color:blue;">stloc</span>.<span style="color:blue;">0</span> 
    L_0007: <span style="color:blue;">br</span>.<span style="color:blue;">s</span> L_000d
    L_0009: <span style="color:blue;">ldloc</span>.<span style="color:blue;">0</span> 
    L_000a: <span style="color:blue;">ldc</span>.<span style="color:blue;">i4</span>.<span style="color:blue;">1</span> 
    L_000b: <span style="color:blue;">add</span> 
    L_000c: <span style="color:blue;">stloc</span>.<span style="color:blue;">0</span> 
    L_000d: <span style="color:blue;">ldloc</span>.<span style="color:blue;">0</span> 
    L_000e: <span style="color:blue;">ldloc</span>.<span style="color:blue;">1</span> 
    L_000f: <span style="color:blue;">blt</span>.<span style="color:blue;">s</span> L_0009
    L_0011: <span style="color:blue;">ret</span> 
<span style="color: #006400;">&#125;</span></pre></div></div>

<p><strong>The generated <a href="http://en.wikipedia.org/wiki/Common_Intermediate_Language">CIL</a> for a while() loop</strong></p>

<div class="wp_syntax"><div class="code"><pre class="cil" style="font-family:monospace;"><span style="color:maroon;font-weight:bold;">.method</span> <span style="color:blue;font-weight:bold;">public</span> <span style="color:blue;font-weight:bold;">hidebysig</span> <span style="color:blue;font-weight:bold;">instance</span> <span style="color:purple;font-weight:bold;">void</span> doWhile<span style="color: #006400;">&#40;</span><span style="color: #006400;">&#41;</span> <span style="color:blue;font-weight:bold;">cil</span> <span style="color:blue;font-weight:bold;">managed</span>
<span style="color: #006400;">&#123;</span>
    <span style="color:maroon;font-weight:bold;">.maxstack</span> <span style="color: #00008B;">3</span>
    <span style="color:maroon;font-weight:bold;">.locals</span> <span style="color:blue;font-weight:bold;">init</span> <span style="color: #006400;">&#40;</span>
        <span style="color: #006400;">&#91;</span><span style="color: #00008B;">0</span><span style="color: #006400;">&#93;</span> <span style="color:purple;font-weight:bold;">int32</span> <span style="color:blue;">i</span><span style="color: #006400;">&#41;</span>
    L_0000: <span style="color:blue;">ldc</span>.<span style="color:blue;">i4</span>.<span style="color:blue;">s</span> <span style="color: #00008B;">100</span>
    L_0002: <span style="color:blue;">stloc</span>.<span style="color:blue;">0</span> 
    L_0003: <span style="color:blue;">ldloc</span>.<span style="color:blue;">0</span> 
    L_0004: <span style="color:blue;">dup</span> 
    L_0005: <span style="color:blue;">ldc</span>.<span style="color:blue;">i4</span>.<span style="color:blue;">1</span> 
    L_0006: <span style="color:blue;">sub</span> 
    L_0007: <span style="color:blue;">stloc</span>.<span style="color:blue;">0</span> 
    L_0008: <span style="color:blue;">brfalse</span>.<span style="color:blue;">s</span> L_0003
    L_000a: <span style="color:blue;">ret</span> 
<span style="color: #006400;">&#125;</span></pre></div></div>

<p>&#160;</p>
<p><strong>The results are in and there is no surprise.</strong></p>
<p>As you can see, the generated <a href="http://en.wikipedia.org/wiki/Common_Intermediate_Language">CIL</a> for a for() loop is larger by 6 instructions. Furthermore, in this code the for() loop initializes 2 local variables rather than 1 (but this may vary depending on your code).</p>
<p>&#160;</p>
<p><strong>What does it all mean?</strong></p>
<p>Probably nothing.&#160; 6 more instructions and an additional variable declaration will in most cases have no impact on the performance, even if you are measuring in microseconds.&#160; I am curious to see what the resulting difference between the loops above would be in other languages.</p>
<p>
				<table cellspacing="0" cellpadding="0" border="0" style="width: 300px; height: 50px; text-align: left; margin-left: auto; margin-right: auto;">
				<tbody>
				<tr>
				<td style="text-align: center;">
				<a href="http://del.icio.us/post?url=http://deserialized.com/comparing-while-loops-with-for-loops-in-c/&title=Comparing while() loops with for() loops in C#" rel="nofollow">
				<img src="http://deserialized.com/wp-content/plugins/addtothis/delicious.png" alt="Add to Del.cio.us" style="border: 0px solid ; width: 48px; height: 48px;"/>
				</a>
				</td>
				<td style="text-align: center;">
				<a href="http://deserialized.com/feed/rss/" rel="nofollow">
				<img src="http://deserialized.com/wp-content/plugins/addtothis/feeds.png" alt="RSS Feed" style="border: 0px solid ; width: 48px; height: 48px;"/>
				</a>
				</td>
				<td style="text-align: center;">
				<a href="http://technorati.com/faves?add=http://deserialized.com/comparing-while-loops-with-for-loops-in-c/" rel="nofollow">
				<img src="http://deserialized.com/wp-content/plugins/addtothis/technorati.png" alt="Add to Technorati Favorites" style="border: 0px solid ; width: 48px; height: 48px;"/>
				</a>
				</td>
				<td style="text-align: center;">
				<a href="http://www.stumbleupon.com/submit?url=http://deserialized.com/comparing-while-loops-with-for-loops-in-c/&title=Comparing while() loops with for() loops in C#" rel="nofollow">
				<img src="http://deserialized.com/wp-content/plugins/addtothis/stumble.png" alt="Stumble It!" style="border: 0px solid ; width: 48px; height: 48px;"/>
				</a>
				
				</td>
				<td style="text-align: center;">
				<a href="http://digg.com/submit?phase=2&url=http://deserialized.com/comparing-while-loops-with-for-loops-in-c/" rel="nofollow">
				<img src="http://deserialized.com/wp-content/plugins/addtothis/digg.png" alt="Digg It!" style="border: 0px solid ; width: 48px; height: 48px;"/>
				</a>
				
				</td>
				</tr>
				<tr><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td style="text-align: right;" ><a href="http://www.sajithmr.com"><img style="border:none" src="http://deserialized.com/wp-content/plugins/addtothis/sajithmr.png"  title="Powered By Sajithmr.com" alt="www.sajithmr.com"/></a></td></tr>
				</tbody>
				</table>

                
		
				</p>]]></content:encoded>
			<wfw:commentRss>http://deserialized.com/comparing-while-loops-with-for-loops-in-c/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>WordPress 2.8 Pretty URLs and IIS6</title>
		<link>http://deserialized.com/wordpress-2-8-pretty-urls-and-iis6/</link>
		<comments>http://deserialized.com/wordpress-2-8-pretty-urls-and-iis6/#comments</comments>
		<pubDate>Tue, 18 Aug 2009 16:10:24 +0000</pubDate>
		<dc:creator>Bryan Migliorisi</dc:creator>
				<category><![CDATA[IIS]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://deserialized.com/?p=8</guid>
		<description><![CDATA[For my first blog post, I thought it would be a good idea to write about the experience and process of setting up WordPress 2.8 on my Windows Server 2003 box with IIS6.  I wanted to enable pretty links (you know, without the ugly index.php prefix), but IIS6 does not support this sort of behavior [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fdeserialized.com%2Fwordpress-2-8-pretty-urls-and-iis6%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fdeserialized.com%2Fwordpress-2-8-pretty-urls-and-iis6%2F&amp;source=BryanMigliorisi&amp;style=normal&amp;service=is.gd" height="61" width="50" /><br />
			</a>
		</div>
<div class="wp-caption alignleft" style="width: 160px"><a href="http://www.wordpress.org"><img class=" " src="http://www.microsoft.com/web/media/gallery/apps-screenshots/wordpress-250x250.png" alt="WordPress" width="150" height="150" /></a><p class="wp-caption-text">WordPress</p></div>
<p>For my first blog post, I thought it would be a good idea to write about the experience and process of setting up WordPress 2.8 on my Windows Server 2003 box with IIS6.  I wanted to enable pretty links (you know, without the ugly index.php prefix), but IIS6 does not support this sort of behavior out of the box.</p>
<p>Yes, I know &#8211; WordPress and PHP belong on Linux but I prefer to think of myself as a Windows developer (C#, ASP.NET), though I work full time developing with PHP, Java\JSP, and JavaScript.</p>
<p>Installing WordPress is pretty straight forward, so I wont bother getting into the easy stuff.  It is just a matter of extracting the files and creating a new web site in the IIS Manager with script execution permissions.  I am going to assume that you already have IIS and PHP running.  If you do not, read up on it at the <a title="IIS6: FastCGI" href="http://forums.iis.net/1103.aspx">IIS6 FastCGI</a> forums on <a href="http://www.iis.net">IIS.net</a>.  You&#8217;ll find that Windows handles PHP and WordPress just fine, but you&#8217;ll be missing one major Linux\Apache feature &#8211; <a href="http://httpd.apache.org/docs/1.3/mod/mod_rewrite.html">mod_rewrite</a>.</p>
<p>mod_rewrite is the module that allows you to create those fancy &#8220;pretty URLs&#8221; that everyone loves so much (yes, I love them too).  IIS6 does not support this out of the box so we will need to install an ISAPI filter to accomplish this for us.  My favorite is the open-source <a title="IIRF" href="http://www.codeplex.com/IIRF">Codeplex project IIRF</a>.  I&#8217;ve used it in a number of projects and it always works out well for me.</p>
<p>For the remainder of this post I am going to assume that you already have a working WordPress installation.  On to the fun part&#8230;</p>
<p><strong>Installing IIRF in IIS6</strong></p>
<p>Download the latest build of IIRF from Codeplex and extract it to somewhere on your hard drive.  I usually have the following structure:</p>
<pre>C:\inetpub\wwwroot\sitename.com
C:\inetpub\wwwroot\sitename.com\www
C:\inetpub\wwwroot\sitename.com\iirf</pre>
<p>I do this to separate the web content from the ISAPI filter.  When you extract the archive, you&#8217;ll find there are a ton of files in there.  Most of them are for testing your rules but you only need the following two files:</p>
<pre>IsapiRewrite4.dll
IsapiRewrite4.ini</pre>
<p>The DLL is the actual ISAPI filter and is the equivalent of mod_rewrite on Apache and the INI file is the configuration file which is the equivalent of an .htaccess file on Apache.</p>
<p>Once you have the files extracted in the correct location you must enable the filter in IIS6.  Start by opening up the IIS Manager.  (I&#8217;ll assume you already know how to do this.)  On the left side, click on the [+] sign to expand the list.  You should see Application Pools, Web Sites, and Web Service Extensions.</p>
<p>Enabling the ISAPI filter is a two step process.  The first step is to add it as a Web Service Extension so click on that list item on the left.  The list of installed ISAPI filters will be shown on the right side.  Click on &#8220;<em>Add a new Web service extension&#8221; </em>and you&#8217;ll see the screen below:</p>
<p><img class="alignnone size-full wp-image-13" title="new-web-service-extension" src="http://deserialized.com/wp-content/uploads/2009/08/new-web-service-extension.png" alt="new-web-service-extension" width="398" height="339" /></p>
<p>You may enter any name, but I would recommend that you enter something that identifies this filter so that you can easily remember what it is for.  A good idea is something like  &#8220;IIRF for MySite.com&#8221;  Once you have chosen a name, you must add the required files.  Click on Add and then click on Browse.  Navigate to the folder that you extracted the IsapiRewrite4.dll file and select it. Press OK.  You should now be looking at the &#8220;New Web Service Extension&#8221; window again, with one file listed in the &#8220;Required files&#8221; list.  Check &#8220;Set extension status to Allowed&#8221; and press OK.</p>
<p>The ISAPI filter is now allowed to run on this web server.  For the second step, you&#8217;ll need to tell IIS which sites will actually execute this filter.  Expand the &#8220;Web Sites&#8221; list by pressing the [+] button on the left.  Right click on the web site that you want to enable IIRF for and click Properties.  Select the &#8220;ISAPI Filters&#8221; tab and click Add.  For filter name you may enter anything you want.  I usually choose &#8220;IIRF&#8221; but you can enter whatever you want.  Next click on Browse and once again navigate to the same  IsapiRewrite4.dll file that you just selected in Step 1. Press OK to return to the web site properties window.  You should now see the filter listed in the filters list.  Assuming it all went according to plan, press OK again to return to the IIS Manager.</p>
<p>You may need to restart IIS at this point so the server loads the new ISAPI filters.</p>
<p><strong>Setting up IIRF rewrite rules</strong></p>
<p>This is the easy part.  IIRF supports many (but not all) of the same rewrite directives that mod_rewrite does.  It is worth noting that mod_rewrite is incredibly powerful and you can usually find rules for doing all sorts of cool things but they might not always work with IIRF due to lack of support with some mod_rewrite directives.  IIRF is still under development so the future may hold some good news, but your mileage may vary.</p>
<p>IsapiRewrite4.ini must reside in the same folder as IsapiRewrite4.dll.  If it does not exist, create the file now.  To enable pretty URLs for WordPress all we need to do is copy the contents of a valid .htaccess file from a typical Linux\Apache WordPress installation, which I have pasted here:</p>
<pre>RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]</pre>
<p>Save IsapiRewrite4.ini and then head over to your WordPress Administration panel.</p>
<p><strong>Enabling Pretty URLs in WordPress</strong></p>
<p>Log in to your WordPress Administration Panel and click on Settings and then on Permalinks.  Click on &#8220;Custom Structure&#8221; and enter the following:</p>
<pre>
/%postname%/
</pre>
<p>Now press Save.  At this point, you should be ready to go.  Head over to your blog and refresh it.  Click on some articles and look at the URL.  You should now have pretty, clean URLs.</p>
<p>
				<table cellspacing="0" cellpadding="0" border="0" style="width: 300px; height: 50px; text-align: left; margin-left: auto; margin-right: auto;">
				<tbody>
				<tr>
				<td style="text-align: center;">
				<a href="http://del.icio.us/post?url=http://deserialized.com/wordpress-2-8-pretty-urls-and-iis6/&title=WordPress 2.8 Pretty URLs and IIS6" rel="nofollow">
				<img src="http://deserialized.com/wp-content/plugins/addtothis/delicious.png" alt="Add to Del.cio.us" style="border: 0px solid ; width: 48px; height: 48px;"/>
				</a>
				</td>
				<td style="text-align: center;">
				<a href="http://deserialized.com/feed/rss/" rel="nofollow">
				<img src="http://deserialized.com/wp-content/plugins/addtothis/feeds.png" alt="RSS Feed" style="border: 0px solid ; width: 48px; height: 48px;"/>
				</a>
				</td>
				<td style="text-align: center;">
				<a href="http://technorati.com/faves?add=http://deserialized.com/wordpress-2-8-pretty-urls-and-iis6/" rel="nofollow">
				<img src="http://deserialized.com/wp-content/plugins/addtothis/technorati.png" alt="Add to Technorati Favorites" style="border: 0px solid ; width: 48px; height: 48px;"/>
				</a>
				</td>
				<td style="text-align: center;">
				<a href="http://www.stumbleupon.com/submit?url=http://deserialized.com/wordpress-2-8-pretty-urls-and-iis6/&title=WordPress 2.8 Pretty URLs and IIS6" rel="nofollow">
				<img src="http://deserialized.com/wp-content/plugins/addtothis/stumble.png" alt="Stumble It!" style="border: 0px solid ; width: 48px; height: 48px;"/>
				</a>
				
				</td>
				<td style="text-align: center;">
				<a href="http://digg.com/submit?phase=2&url=http://deserialized.com/wordpress-2-8-pretty-urls-and-iis6/" rel="nofollow">
				<img src="http://deserialized.com/wp-content/plugins/addtothis/digg.png" alt="Digg It!" style="border: 0px solid ; width: 48px; height: 48px;"/>
				</a>
				
				</td>
				</tr>
				<tr><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td style="text-align: right;" ><a href="http://www.sajithmr.com"><img style="border:none" src="http://deserialized.com/wp-content/plugins/addtothis/sajithmr.png"  title="Powered By Sajithmr.com" alt="www.sajithmr.com"/></a></td></tr>
				</tbody>
				</table>

                
		
				</p>]]></content:encoded>
			<wfw:commentRss>http://deserialized.com/wordpress-2-8-pretty-urls-and-iis6/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>Hello world!</title>
		<link>http://deserialized.com/hello-world/</link>
		<comments>http://deserialized.com/hello-world/#comments</comments>
		<pubDate>Tue, 18 Aug 2009 02:28:49 +0000</pubDate>
		<dc:creator>Bryan Migliorisi</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://deserialized.com/?p=1</guid>
		<description><![CDATA[Hello world. This has been a long time coming &#8211; a blog. Somehow I managed to escape from blogging for the past several years but here I am now. There have been so many topics brewing in my head. Being a full time web developer for a kick ass company means that I am constantly [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fdeserialized.com%2Fhello-world%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fdeserialized.com%2Fhello-world%2F&amp;source=BryanMigliorisi&amp;style=normal&amp;service=is.gd" height="61" width="50" /><br />
			</a>
		</div>
<p>Hello world.</p>
<p>This has been a long time coming &#8211; a blog.  Somehow I managed to escape from blogging for the past several years but here I am now.  There have been so many topics brewing in my head.  Being a full time web developer for a kick ass company means that I am constantly tackling hard to solve problems and that means that there are always light bulbs going on over my head.  I decided today that it is time to begin sharing those thoughts.  </p>
<p>This blog will be about web development, web security, personal projects, and general programming.  I don&#8217;t claim to be the best programmer alive, so some of the things I&#8217;ll write may not impress you &#8211; that&#8217;s ok, just don&#8217;t flame me.  If you find what I say interesting, let me know.</p>
<p>It is time to start writing for real now.  Until then&#8230;.</p>
<p>
				<table cellspacing="0" cellpadding="0" border="0" style="width: 300px; height: 50px; text-align: left; margin-left: auto; margin-right: auto;">
				<tbody>
				<tr>
				<td style="text-align: center;">
				<a href="http://del.icio.us/post?url=http://deserialized.com/hello-world/&title=Hello world!" rel="nofollow">
				<img src="http://deserialized.com/wp-content/plugins/addtothis/delicious.png" alt="Add to Del.cio.us" style="border: 0px solid ; width: 48px; height: 48px;"/>
				</a>
				</td>
				<td style="text-align: center;">
				<a href="http://deserialized.com/feed/rss/" rel="nofollow">
				<img src="http://deserialized.com/wp-content/plugins/addtothis/feeds.png" alt="RSS Feed" style="border: 0px solid ; width: 48px; height: 48px;"/>
				</a>
				</td>
				<td style="text-align: center;">
				<a href="http://technorati.com/faves?add=http://deserialized.com/hello-world/" rel="nofollow">
				<img src="http://deserialized.com/wp-content/plugins/addtothis/technorati.png" alt="Add to Technorati Favorites" style="border: 0px solid ; width: 48px; height: 48px;"/>
				</a>
				</td>
				<td style="text-align: center;">
				<a href="http://www.stumbleupon.com/submit?url=http://deserialized.com/hello-world/&title=Hello world!" rel="nofollow">
				<img src="http://deserialized.com/wp-content/plugins/addtothis/stumble.png" alt="Stumble It!" style="border: 0px solid ; width: 48px; height: 48px;"/>
				</a>
				
				</td>
				<td style="text-align: center;">
				<a href="http://digg.com/submit?phase=2&url=http://deserialized.com/hello-world/" rel="nofollow">
				<img src="http://deserialized.com/wp-content/plugins/addtothis/digg.png" alt="Digg It!" style="border: 0px solid ; width: 48px; height: 48px;"/>
				</a>
				
				</td>
				</tr>
				<tr><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td style="text-align: right;" ><a href="http://www.sajithmr.com"><img style="border:none" src="http://deserialized.com/wp-content/plugins/addtothis/sajithmr.png"  title="Powered By Sajithmr.com" alt="www.sajithmr.com"/></a></td></tr>
				</tbody>
				</table>

                
		
				</p>]]></content:encoded>
			<wfw:commentRss>http://deserialized.com/hello-world/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
<!-- Loaded originally in 5.42 seconds (2010-09-0