<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>Software Ramblings</title>
	
	<link>http://softwareramblings.com</link>
	<description>Stephen Doyle's Ramblings on Software Engineering</description>
	<lastBuildDate>Fri, 29 Jan 2010 15:22:08 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/SoftwareRamblings" /><feedburner:info uri="softwareramblings" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>Post-Increment vs Pre-Increment</title>
		<link>http://feedproxy.google.com/~r/SoftwareRamblings/~3/g4nO6Xo3heU/post-increment-vs-pre-increment.html</link>
		<comments>http://softwareramblings.com/2010/01/post-increment-vs-pre-increment.html#comments</comments>
		<pubDate>Fri, 29 Jan 2010 13:56:45 +0000</pubDate>
		<dc:creator>Stephen Doyle</dc:creator>
				<category><![CDATA[C++]]></category>

		<guid isPermaLink="false">http://softwareramblings.com/?p=317</guid>
		<description><![CDATA[There is a well known C++ BKM for preferring pre-increment (++i) over post-increment (i++). The rationale is that when post-incrementing and object, the object must increment itself and then return a temporary containing its old value. While this makes perfect sense for complex types (e.g. STL iterators) I&#8217;ve always wondered if it holds true for [...]]]></description>
			<content:encoded><![CDATA[<p>There is a well known C++ BKM for preferring pre-increment (<code>++i</code>) over post-increment (<code>i++</code>). The rationale is that when post-incrementing and object, the object must increment itself and then return a temporary containing its old value. While this makes perfect sense for complex types (e.g. STL iterators) I&#8217;ve always wondered if it holds true for built-in types such as <code>int</code>. Let&#8217;s find out.</p>
<p>First let&#8217;s create a trivial example to examine:</p>
<pre class="brush: cpp;">
#include &lt;iostream&gt;

using namespace std;

int main()
{
	// post-imcrement
	for(int i=0; i&lt;10; i++)
	{
		cout &lt;&lt; &quot;[&quot; &lt;&lt; i &lt;&lt; &quot;]&quot; &lt;&lt; endl;
	}

	// pre-imcrement
	for(int i=0; i&lt;10; ++i)
	{
		cout &lt;&lt; &quot;[&quot; &lt;&lt; i &lt;&lt; &quot;]&quot; &lt;&lt; endl;
	}

	return 0;
}
</pre>
<p>Now using the Visual Studio 2008 C++ compiler, let&#8217;s take a look at the generated assembly code. First let&#8217;s keep things simple and disable compiler optimizations (/Od):</p>
<pre class="brush: cpp; highlight: [5,6,7,8,18,19,20,21];">
	// post-imcrement
	for(int i=0; i&lt;10; i++)
004114D3  mov         dword ptr [i],0
004114D5  jmp         main+30h (4114E0h)
004114D7  mov         eax,dword ptr [i]
004114DA  add         eax,1
004114DD  mov         dword ptr [i],eax
004114E0  cmp         dword ptr [i],0Ah
004114E4  jge         main+86h (411536h)
	{

&lt;... snip ...&gt;

	// pre-imcrement
	for(int i=0; i&lt;10; ++i)
00411536  mov         dword ptr [i],0
0041153D  jmp         main+98h (411548h)
0041153F  mov         eax,dword ptr [i]
00411542  add         eax,1
00411545  mov         dword ptr [i],eax
00411548  cmp         dword ptr [i],0Ah
0041154C  jge         main+0EEh (41159Eh)
	{
</pre>
<p>The relevant parts of the assembly code are highlighted. As you can see, there is no difference between the generated code for post-increment and pre-increment. </p>
<p>Now, with compiler optimizations enabled (\O2) and the relevant parts highlighted:</p>
<pre class="brush: cpp; highlight: [7,8,17,18];">
	// post-imcrement
	for(int i=0; i&lt;10; i++)
00401008  xor         esi,esi
0040100A  lea         ebx,[ebx]
	{
&lt;... snip ...&gt;
0040104A  inc         esi
0040104B  cmp         esi,0Ah
0040104E  jl          main+10h (401010h)
	}

	// pre-imcrement
	for(int i=0; i&lt;10; ++i)
00401050  xor         esi,esi
	{
&lt;... snip ...&gt;
0040108C  inc         esi
0040108D  cmp         esi,0Ah
00401090  jl          main+52h (401052h)
	}
</pre>
<p>Again there is no difference in the generated assembly between post-increment and pre-increment.</p>
<p>So, based on this quick experiment, there is no difference between pre-increment and post-increment for <code>int</code> types when using the Visual Studio 2008 C++ compiler with optimizations enabled or disabled. </p>
<p>Note that this doesn&#8217;t change the BKM to prefer pre-increments over post-increments when using integer types. The above experiment was only conducted with a single compiler &#8211; other compilers may behave differently and so it is best to err on the side of caution and use pre-increments where possible. Also, the use of pre-increment adds some future proofing &#8211; if the type of the variable being incremented changed to a more complex type then pre-increment then becomes the optimal choice.</p>
<p align="left"><a class="tt" href="http://twitter.com/home/?status=Post-Increment+vs+Pre-Increment+http://girep.th8.us" title="Post to Twitter"><img class="nothumb" src="http://softwareramblings.com/wp-content/plugins/tweet-this/icons/tt-twitter.png" alt="Post to Twitter" /></a> <a class="tt" href="http://twitter.com/home/?status=Post-Increment+vs+Pre-Increment+http://girep.th8.us" title="Post to Twitter">Tweet This Post</a> <a class="tt" href="http://digg.com/submit?url=http://softwareramblings.com/2010/01/post-increment-vs-pre-increment.html&amp;title=Post-Increment+vs+Pre-Increment" title="Post to Digg"><img class="nothumb" src="http://softwareramblings.com/wp-content/plugins/tweet-this/icons/tt-digg.png" alt="Post to Digg" /></a> <a class="tt" href="http://digg.com/submit?url=http://softwareramblings.com/2010/01/post-increment-vs-pre-increment.html&amp;title=Post-Increment+vs+Pre-Increment" title="Post to Digg">Digg This Post</a> <a class="tt" href="http://reddit.com/submit?url=http://softwareramblings.com/2010/01/post-increment-vs-pre-increment.html&amp;title=Post-Increment+vs+Pre-Increment" title="Post to Reddit"><img class="nothumb" src="http://softwareramblings.com/wp-content/plugins/tweet-this/icons/tt-reddit.png" alt="Post to Reddit" /></a> <a class="tt" href="http://reddit.com/submit?url=http://softwareramblings.com/2010/01/post-increment-vs-pre-increment.html&amp;title=Post-Increment+vs+Pre-Increment" title="Post to Reddit">Reddit</a> <a class="tt" href="http://stumbleupon.com/submit?url=http://softwareramblings.com/2010/01/post-increment-vs-pre-increment.html&amp;title=Post-Increment+vs+Pre-Increment" title="Post to StumbleUpon"><img class="nothumb" src="http://softwareramblings.com/wp-content/plugins/tweet-this/icons/tt-su.png" alt="Post to StumbleUpon" /></a> <a class="tt" href="http://stumbleupon.com/submit?url=http://softwareramblings.com/2010/01/post-increment-vs-pre-increment.html&amp;title=Post-Increment+vs+Pre-Increment" title="Post to StumbleUpon">Stumble This Post</a></p><img src="http://feeds.feedburner.com/~r/SoftwareRamblings/~4/g4nO6Xo3heU" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://softwareramblings.com/2010/01/post-increment-vs-pre-increment.html/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		<feedburner:origLink>http://softwareramblings.com/2010/01/post-increment-vs-pre-increment.html</feedburner:origLink></item>
		<item>
		<title>countloc v0.4 released</title>
		<link>http://feedproxy.google.com/~r/SoftwareRamblings/~3/yccO7xWOtWA/countloc-v0-4-released.html</link>
		<comments>http://softwareramblings.com/2009/12/countloc-v0-4-released.html#comments</comments>
		<pubDate>Fri, 18 Dec 2009 12:08:21 +0000</pubDate>
		<dc:creator>Stephen Doyle</dc:creator>
				<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://softwareramblings.com/?p=270</guid>
		<description><![CDATA[In the absence of independent user feedback, a good way to approximate independent feedback is to write something, not look at it for a while and then try to read/use it. I was reminded of this recently when I tried to use my countloc app to gather some project LOC metrics. I had written this [...]]]></description>
			<content:encoded><![CDATA[<p>In the absence of independent user feedback, a good way to approximate independent feedback is to write something, not look at it for a while and then try to read/use it. I was reminded of this recently when I tried to use my <a href="http://countloc.rubyforge.org/">countloc</a> app to gather some project LOC metrics. I had written this particular version about a year ago and hadn&#8217;t used it in a while. After dusting off the mothballs and invoking the help, it took me two attempts to get it to work properly. I was not impressed. I was also worried that the hundred or so other people that <a href="http://rubyforge.org/projects/countloc/">downloaded</a> it had a similar experience of finding that it was not as usable as it should be.</p>
<p>I&#8217;ve hopefully fixed the usability problems in the latest version &#8211; <a href="http://rubyforge.org/frs/?group_id=7555">countloc v0.4</a>. I&#8217;ve also fixed a few bugs and added in some feature requests that I had received via the <a href="http://rubyforge.org/projects/countloc/">RubyForge</a> page. </p>
<p>If you do give this app a twirl please provide feedback via the RubyForge area on any issues encountered.</p>
<p>Note: The app is implemented in Ruby and the download also contains the source code. I would be interested in hearing from any Ruby gurus out there on any suggestions for improving the code. I&#8217;ve set up a <a href="http://rubyforge.org/forum/forum.php?thread_id=46963&#038;forum_id=29326">thread</a> in the forum area for providing feedback.</p>
<p align="left"><a class="tt" href="http://twitter.com/home/?status=countloc+v0.4+released+http://w9g3e.th8.us" title="Post to Twitter"><img class="nothumb" src="http://softwareramblings.com/wp-content/plugins/tweet-this/icons/tt-twitter.png" alt="Post to Twitter" /></a> <a class="tt" href="http://twitter.com/home/?status=countloc+v0.4+released+http://w9g3e.th8.us" title="Post to Twitter">Tweet This Post</a> <a class="tt" href="http://digg.com/submit?url=http://softwareramblings.com/2009/12/countloc-v0-4-released.html&amp;title=countloc+v0.4+released" title="Post to Digg"><img class="nothumb" src="http://softwareramblings.com/wp-content/plugins/tweet-this/icons/tt-digg.png" alt="Post to Digg" /></a> <a class="tt" href="http://digg.com/submit?url=http://softwareramblings.com/2009/12/countloc-v0-4-released.html&amp;title=countloc+v0.4+released" title="Post to Digg">Digg This Post</a> <a class="tt" href="http://reddit.com/submit?url=http://softwareramblings.com/2009/12/countloc-v0-4-released.html&amp;title=countloc+v0.4+released" title="Post to Reddit"><img class="nothumb" src="http://softwareramblings.com/wp-content/plugins/tweet-this/icons/tt-reddit.png" alt="Post to Reddit" /></a> <a class="tt" href="http://reddit.com/submit?url=http://softwareramblings.com/2009/12/countloc-v0-4-released.html&amp;title=countloc+v0.4+released" title="Post to Reddit">Reddit</a> <a class="tt" href="http://stumbleupon.com/submit?url=http://softwareramblings.com/2009/12/countloc-v0-4-released.html&amp;title=countloc+v0.4+released" title="Post to StumbleUpon"><img class="nothumb" src="http://softwareramblings.com/wp-content/plugins/tweet-this/icons/tt-su.png" alt="Post to StumbleUpon" /></a> <a class="tt" href="http://stumbleupon.com/submit?url=http://softwareramblings.com/2009/12/countloc-v0-4-released.html&amp;title=countloc+v0.4+released" title="Post to StumbleUpon">Stumble This Post</a></p><img src="http://feeds.feedburner.com/~r/SoftwareRamblings/~4/yccO7xWOtWA" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://softwareramblings.com/2009/12/countloc-v0-4-released.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://softwareramblings.com/2009/12/countloc-v0-4-released.html</feedburner:origLink></item>
		<item>
		<title>CodeKata – Kata Eighteen Solution</title>
		<link>http://feedproxy.google.com/~r/SoftwareRamblings/~3/fi3IibV9mmE/codekata-kata-eighteen-solution.html</link>
		<comments>http://softwareramblings.com/2009/11/codekata-kata-eighteen-solution.html#comments</comments>
		<pubDate>Sat, 07 Nov 2009 23:02:23 +0000</pubDate>
		<dc:creator>Stephen Doyle</dc:creator>
				<category><![CDATA[Ruby]]></category>
		<category><![CDATA[CodeKata]]></category>

		<guid isPermaLink="false">http://softwareramblings.com/?p=268</guid>
		<description><![CDATA[Kata Eighteen requires some code to calculate transitive dependencies, i.e. how dependencies propagate between things. Here is my solution.

class Dependencies

  def initialize()
    @direct = Hash.new
  end

  def add_direct(item, dependants)
    @direct[item] = dependants
  end

  def dependencies_for(item)
    dependants = []
    [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://codekata.pragprog.com/2007/01/kata_eighteen_t.html">Kata Eighteen</a> requires some code to calculate transitive dependencies, i.e. how dependencies propagate between things. Here is my solution.</p>
<pre class="brush: ruby;">
class Dependencies

  def initialize()
    @direct = Hash.new
  end

  def add_direct(item, dependants)
    @direct[item] = dependants
  end

  def dependencies_for(item)
    dependants = []
    toBeProcessed = @direct[item].clone
    while not toBeProcessed.empty?
      x = toBeProcessed.shift
      if x != item and not dependants.include?(x)
        dependants &lt;&lt; x
        toBeProcessed.concat(@direct[x]) if @direct.include?(x)
      end
    end
    return dependants.sort!
  end

end
</pre>
<p align="left"><a class="tt" href="http://twitter.com/home/?status=CodeKata+%26%238211%3B+Kata+Eighteen+Solution+http://q92ts.th8.us" title="Post to Twitter"><img class="nothumb" src="http://softwareramblings.com/wp-content/plugins/tweet-this/icons/tt-twitter.png" alt="Post to Twitter" /></a> <a class="tt" href="http://twitter.com/home/?status=CodeKata+%26%238211%3B+Kata+Eighteen+Solution+http://q92ts.th8.us" title="Post to Twitter">Tweet This Post</a> <a class="tt" href="http://digg.com/submit?url=http://softwareramblings.com/2009/11/codekata-kata-eighteen-solution.html&amp;title=CodeKata+%26%238211%3B+Kata+Eighteen+Solution" title="Post to Digg"><img class="nothumb" src="http://softwareramblings.com/wp-content/plugins/tweet-this/icons/tt-digg.png" alt="Post to Digg" /></a> <a class="tt" href="http://digg.com/submit?url=http://softwareramblings.com/2009/11/codekata-kata-eighteen-solution.html&amp;title=CodeKata+%26%238211%3B+Kata+Eighteen+Solution" title="Post to Digg">Digg This Post</a> <a class="tt" href="http://reddit.com/submit?url=http://softwareramblings.com/2009/11/codekata-kata-eighteen-solution.html&amp;title=CodeKata+%26%238211%3B+Kata+Eighteen+Solution" title="Post to Reddit"><img class="nothumb" src="http://softwareramblings.com/wp-content/plugins/tweet-this/icons/tt-reddit.png" alt="Post to Reddit" /></a> <a class="tt" href="http://reddit.com/submit?url=http://softwareramblings.com/2009/11/codekata-kata-eighteen-solution.html&amp;title=CodeKata+%26%238211%3B+Kata+Eighteen+Solution" title="Post to Reddit">Reddit</a> <a class="tt" href="http://stumbleupon.com/submit?url=http://softwareramblings.com/2009/11/codekata-kata-eighteen-solution.html&amp;title=CodeKata+%26%238211%3B+Kata+Eighteen+Solution" title="Post to StumbleUpon"><img class="nothumb" src="http://softwareramblings.com/wp-content/plugins/tweet-this/icons/tt-su.png" alt="Post to StumbleUpon" /></a> <a class="tt" href="http://stumbleupon.com/submit?url=http://softwareramblings.com/2009/11/codekata-kata-eighteen-solution.html&amp;title=CodeKata+%26%238211%3B+Kata+Eighteen+Solution" title="Post to StumbleUpon">Stumble This Post</a></p><img src="http://feeds.feedburner.com/~r/SoftwareRamblings/~4/fi3IibV9mmE" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://softwareramblings.com/2009/11/codekata-kata-eighteen-solution.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://softwareramblings.com/2009/11/codekata-kata-eighteen-solution.html</feedburner:origLink></item>
		<item>
		<title>CodeKata – Kata Five Solution</title>
		<link>http://feedproxy.google.com/~r/SoftwareRamblings/~3/WclGPzA2OZ8/codekata-kata-five-solution.html</link>
		<comments>http://softwareramblings.com/2009/11/codekata-kata-five-solution.html#comments</comments>
		<pubDate>Wed, 04 Nov 2009 00:36:13 +0000</pubDate>
		<dc:creator>Stephen Doyle</dc:creator>
				<category><![CDATA[Ruby]]></category>
		<category><![CDATA[CodeKata]]></category>

		<guid isPermaLink="false">http://softwareramblings.com/?p=265</guid>
		<description><![CDATA[Kata five requires the implementation of a Bloom filter. Here is my solution in Ruby using a non-optimized bitmap implementation and a reduced MD5 digest for the hashing functions.

class BloomFilter

  def initialize(dictionary, num_bits, num_hashes)
    @bitmap = Bitmap.new(num_bits)
    @hashes = Array.new(num_hashes) { &#124;i&#124; BloomHash.new(i, num_bits-1) }

    [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://codekata.pragprog.com/2007/01/kata_five_bloom.html">Kata five</a> requires the implementation of a <a href="http://en.wikipedia.org/wiki/Bloom_filter">Bloom filter</a>. Here is my solution in Ruby using a non-optimized bitmap implementation and a reduced MD5 digest for the hashing functions.</p>
<pre class="brush: ruby;">
class BloomFilter

  def initialize(dictionary, num_bits, num_hashes)
    @bitmap = Bitmap.new(num_bits)
    @hashes = Array.new(num_hashes) { |i| BloomHash.new(i, num_bits-1) }

    # compute the hash values for each word in the dictionary
    # and set the appropriate bits in the bitmap
    File.new(dictionary, 'r').each_line do |word|
      @hashes.each { |h| @bitmap[h.compute(word.chomp)] = 1 }
    end
  end

  def search(word)
    @hashes.each { |h| return false if @bitmap[h.compute(word)] == 0 }
    return true
  end

end

class BloomHash

  def initialize(seed, max_value)
    @offset = seed
    @num_digits = 0
    @max_value = max_value
    while(max_value &gt; 0) do
      @num_digits += 1
      max_value &gt;&gt;= 4
    end
  end

  def compute(word)
    digest = Digest::MD5.hexdigest(word)
    return digest[@offset, @num_digits].to_i(16) % @max_value
  end

end

class Bitmap &lt; Array

  def initialize(size)
    super(size)
    self.fill(0)
  end

end
</pre>
<p align="left"><a class="tt" href="http://twitter.com/home/?status=CodeKata+%26%238211%3B+Kata+Five+Solution+http://zboz8.th8.us" title="Post to Twitter"><img class="nothumb" src="http://softwareramblings.com/wp-content/plugins/tweet-this/icons/tt-twitter.png" alt="Post to Twitter" /></a> <a class="tt" href="http://twitter.com/home/?status=CodeKata+%26%238211%3B+Kata+Five+Solution+http://zboz8.th8.us" title="Post to Twitter">Tweet This Post</a> <a class="tt" href="http://digg.com/submit?url=http://softwareramblings.com/2009/11/codekata-kata-five-solution.html&amp;title=CodeKata+%26%238211%3B+Kata+Five+Solution" title="Post to Digg"><img class="nothumb" src="http://softwareramblings.com/wp-content/plugins/tweet-this/icons/tt-digg.png" alt="Post to Digg" /></a> <a class="tt" href="http://digg.com/submit?url=http://softwareramblings.com/2009/11/codekata-kata-five-solution.html&amp;title=CodeKata+%26%238211%3B+Kata+Five+Solution" title="Post to Digg">Digg This Post</a> <a class="tt" href="http://reddit.com/submit?url=http://softwareramblings.com/2009/11/codekata-kata-five-solution.html&amp;title=CodeKata+%26%238211%3B+Kata+Five+Solution" title="Post to Reddit"><img class="nothumb" src="http://softwareramblings.com/wp-content/plugins/tweet-this/icons/tt-reddit.png" alt="Post to Reddit" /></a> <a class="tt" href="http://reddit.com/submit?url=http://softwareramblings.com/2009/11/codekata-kata-five-solution.html&amp;title=CodeKata+%26%238211%3B+Kata+Five+Solution" title="Post to Reddit">Reddit</a> <a class="tt" href="http://stumbleupon.com/submit?url=http://softwareramblings.com/2009/11/codekata-kata-five-solution.html&amp;title=CodeKata+%26%238211%3B+Kata+Five+Solution" title="Post to StumbleUpon"><img class="nothumb" src="http://softwareramblings.com/wp-content/plugins/tweet-this/icons/tt-su.png" alt="Post to StumbleUpon" /></a> <a class="tt" href="http://stumbleupon.com/submit?url=http://softwareramblings.com/2009/11/codekata-kata-five-solution.html&amp;title=CodeKata+%26%238211%3B+Kata+Five+Solution" title="Post to StumbleUpon">Stumble This Post</a></p><img src="http://feeds.feedburner.com/~r/SoftwareRamblings/~4/WclGPzA2OZ8" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://softwareramblings.com/2009/11/codekata-kata-five-solution.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://softwareramblings.com/2009/11/codekata-kata-five-solution.html</feedburner:origLink></item>
		<item>
		<title>Multi-thread scaling issues with Ruby [update]</title>
		<link>http://feedproxy.google.com/~r/SoftwareRamblings/~3/UCRiLVxmB6A/multi-thread-scaling-issues-with-ruby-update.html</link>
		<comments>http://softwareramblings.com/2009/11/multi-thread-scaling-issues-with-ruby-update.html#comments</comments>
		<pubDate>Tue, 03 Nov 2009 15:29:20 +0000</pubDate>
		<dc:creator>Stephen Doyle</dc:creator>
				<category><![CDATA[Multithreading]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://softwareramblings.com/?p=262</guid>
		<description><![CDATA[In my previous post on Multi-thread scaling issues with Python and Ruby, I had described the threading implementation within Ruby as using green threads. It seems that this has changed in Ruby 1.9 &#8230;
Ruby 1.9 threads do map to native threads, unfortunately the 1.9 interpreter forces user created threads to acquire a global mutex lock [...]]]></description>
			<content:encoded><![CDATA[<p>In my previous post on <a href="http://softwareramblings.com/2008/07/multi-thread-scaling-issues-with-python-and-ruby.html">Multi-thread scaling issues with Python and Ruby</a>, I had described the threading implementation within Ruby as using <a href="http://en.wikipedia.org/wiki/Green_threads">green threads</a>. It seems that this has changed in Ruby 1.9 &#8230;</p>
<blockquote><p>Ruby 1.9 threads do map to native threads, unfortunately the 1.9 interpreter forces user created threads to acquire a global mutex lock before executing. The upshot is that 1.9 thread execution is serialized and unable to benefit from multiple cores.</p></blockquote>
<p>See <a href="http://www.klankboomklang.com/2009/10/31/ruby-in-a-multicore-world/">Ruby in a multicore world</a> for further discussion.</p>
<p align="left"><a class="tt" href="http://twitter.com/home/?status=Multi-thread+scaling+issues+with+Ruby+%5Bupdate%5D+http://99whb.th8.us" title="Post to Twitter"><img class="nothumb" src="http://softwareramblings.com/wp-content/plugins/tweet-this/icons/tt-twitter.png" alt="Post to Twitter" /></a> <a class="tt" href="http://twitter.com/home/?status=Multi-thread+scaling+issues+with+Ruby+%5Bupdate%5D+http://99whb.th8.us" title="Post to Twitter">Tweet This Post</a> <a class="tt" href="http://digg.com/submit?url=http://softwareramblings.com/2009/11/multi-thread-scaling-issues-with-ruby-update.html&amp;title=Multi-thread+scaling+issues+with+Ruby+%5Bupdate%5D" title="Post to Digg"><img class="nothumb" src="http://softwareramblings.com/wp-content/plugins/tweet-this/icons/tt-digg.png" alt="Post to Digg" /></a> <a class="tt" href="http://digg.com/submit?url=http://softwareramblings.com/2009/11/multi-thread-scaling-issues-with-ruby-update.html&amp;title=Multi-thread+scaling+issues+with+Ruby+%5Bupdate%5D" title="Post to Digg">Digg This Post</a> <a class="tt" href="http://reddit.com/submit?url=http://softwareramblings.com/2009/11/multi-thread-scaling-issues-with-ruby-update.html&amp;title=Multi-thread+scaling+issues+with+Ruby+%5Bupdate%5D" title="Post to Reddit"><img class="nothumb" src="http://softwareramblings.com/wp-content/plugins/tweet-this/icons/tt-reddit.png" alt="Post to Reddit" /></a> <a class="tt" href="http://reddit.com/submit?url=http://softwareramblings.com/2009/11/multi-thread-scaling-issues-with-ruby-update.html&amp;title=Multi-thread+scaling+issues+with+Ruby+%5Bupdate%5D" title="Post to Reddit">Reddit</a> <a class="tt" href="http://stumbleupon.com/submit?url=http://softwareramblings.com/2009/11/multi-thread-scaling-issues-with-ruby-update.html&amp;title=Multi-thread+scaling+issues+with+Ruby+%5Bupdate%5D" title="Post to StumbleUpon"><img class="nothumb" src="http://softwareramblings.com/wp-content/plugins/tweet-this/icons/tt-su.png" alt="Post to StumbleUpon" /></a> <a class="tt" href="http://stumbleupon.com/submit?url=http://softwareramblings.com/2009/11/multi-thread-scaling-issues-with-ruby-update.html&amp;title=Multi-thread+scaling+issues+with+Ruby+%5Bupdate%5D" title="Post to StumbleUpon">Stumble This Post</a></p><img src="http://feeds.feedburner.com/~r/SoftwareRamblings/~4/UCRiLVxmB6A" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://softwareramblings.com/2009/11/multi-thread-scaling-issues-with-ruby-update.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://softwareramblings.com/2009/11/multi-thread-scaling-issues-with-ruby-update.html</feedburner:origLink></item>
		<item>
		<title>CodeKata – Kata Two Solution</title>
		<link>http://feedproxy.google.com/~r/SoftwareRamblings/~3/cWqHTFSepww/codekata-kata-two-solution.html</link>
		<comments>http://softwareramblings.com/2009/11/codekata-kata-two-solution.html#comments</comments>
		<pubDate>Tue, 03 Nov 2009 14:45:59 +0000</pubDate>
		<dc:creator>Stephen Doyle</dc:creator>
				<category><![CDATA[Ruby]]></category>
		<category><![CDATA[CodeKata]]></category>

		<guid isPermaLink="false">http://softwareramblings.com/?p=252</guid>
		<description><![CDATA[Dave Thomas maintains a blog of &#8220;Code Kata&#8217;s&#8221;. He describes a code kata as being a practice session for practicing coding skills:
Each is a short exercise (perhaps 30 minutes to an hour long). Some involve programming, and can be coded in many different ways. Some are open ended, and involve thinking about the issues behind programming. These [...]]]></description>
			<content:encoded><![CDATA[<p>Dave Thomas maintains a <a href="http://codekata.pragprog.com/2007/01/code_kata_backg.html">blog of &#8220;Code Kata&#8217;s&#8221;</a>. He describes a code kata as being a practice session for practicing coding skills:</p>
<blockquote><p>Each is a short exercise (perhaps 30 minutes to an hour long). Some involve programming, and can be coded in many different ways. Some are open ended, and involve thinking about the issues behind programming. These are unlikely to have a single correct answer.</p></blockquote>
<p>Here are two of my solutions for <a href="http://codekata.pragprog.com/2007/01/kata_two_karate.html">kata two</a> using Ruby. The first uses recursion and the second uses an iterative approach.</p>
<p>Recursive solution &#8230;</p>
<pre class="brush: ruby;">
# Recursive implementation
def chop(target, values)
  # Special handling for zero and single element arrays
  return -1 if values.empty?

  return ((target == values[0]) ? 0 : -1) if values.length == 1

  # Try the bottom half first
  pos = chop(target, values[0, values.length/2])
  return pos if pos != -1

  # Then the upper half ... remember that the returned
  # position is relative to the middle of the array.
  pos = chop(target, values[values.length/2, values.length-1])
  return pos + (values.length/2) if pos != -1

  # Didn't find what we were looking for
  return -1
end
</pre>
<p>Iterative solution &#8230;</p>
<pre class="brush: ruby;">
# Iterative implementation
def chop(target, values)
  start = 0
  stop = values.length  # stop indexes one past the end of the array

  # loop until something is found or until we
  # run out of elements to search
  while start != stop
    # Find the middle
    mid = start + (stop - start) / 2

    # Check to see if we got lucky
    return mid if values[mid] == target

    # Not this time ... so lets see which half it might be in
    if target &lt; values[pos]
      stop = mid
    else
      start = mid + 1
    end
  end

  # Didn't find what we were looking for
  return -1
end
</pre>
<p align="left"><a class="tt" href="http://twitter.com/home/?status=CodeKata+%26%238211%3B+Kata+Two+Solution+http://g6f2z.th8.us" title="Post to Twitter"><img class="nothumb" src="http://softwareramblings.com/wp-content/plugins/tweet-this/icons/tt-twitter.png" alt="Post to Twitter" /></a> <a class="tt" href="http://twitter.com/home/?status=CodeKata+%26%238211%3B+Kata+Two+Solution+http://g6f2z.th8.us" title="Post to Twitter">Tweet This Post</a> <a class="tt" href="http://digg.com/submit?url=http://softwareramblings.com/2009/11/codekata-kata-two-solution.html&amp;title=CodeKata+%26%238211%3B+Kata+Two+Solution" title="Post to Digg"><img class="nothumb" src="http://softwareramblings.com/wp-content/plugins/tweet-this/icons/tt-digg.png" alt="Post to Digg" /></a> <a class="tt" href="http://digg.com/submit?url=http://softwareramblings.com/2009/11/codekata-kata-two-solution.html&amp;title=CodeKata+%26%238211%3B+Kata+Two+Solution" title="Post to Digg">Digg This Post</a> <a class="tt" href="http://reddit.com/submit?url=http://softwareramblings.com/2009/11/codekata-kata-two-solution.html&amp;title=CodeKata+%26%238211%3B+Kata+Two+Solution" title="Post to Reddit"><img class="nothumb" src="http://softwareramblings.com/wp-content/plugins/tweet-this/icons/tt-reddit.png" alt="Post to Reddit" /></a> <a class="tt" href="http://reddit.com/submit?url=http://softwareramblings.com/2009/11/codekata-kata-two-solution.html&amp;title=CodeKata+%26%238211%3B+Kata+Two+Solution" title="Post to Reddit">Reddit</a> <a class="tt" href="http://stumbleupon.com/submit?url=http://softwareramblings.com/2009/11/codekata-kata-two-solution.html&amp;title=CodeKata+%26%238211%3B+Kata+Two+Solution" title="Post to StumbleUpon"><img class="nothumb" src="http://softwareramblings.com/wp-content/plugins/tweet-this/icons/tt-su.png" alt="Post to StumbleUpon" /></a> <a class="tt" href="http://stumbleupon.com/submit?url=http://softwareramblings.com/2009/11/codekata-kata-two-solution.html&amp;title=CodeKata+%26%238211%3B+Kata+Two+Solution" title="Post to StumbleUpon">Stumble This Post</a></p><img src="http://feeds.feedburner.com/~r/SoftwareRamblings/~4/cWqHTFSepww" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://softwareramblings.com/2009/11/codekata-kata-two-solution.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://softwareramblings.com/2009/11/codekata-kata-two-solution.html</feedburner:origLink></item>
		<item>
		<title>ScrumButs</title>
		<link>http://feedproxy.google.com/~r/SoftwareRamblings/~3/AdFgh9lf2os/scrumbuts.html</link>
		<comments>http://softwareramblings.com/2009/09/scrumbuts.html#comments</comments>
		<pubDate>Fri, 04 Sep 2009 00:35:18 +0000</pubDate>
		<dc:creator>Stephen Doyle</dc:creator>
				<category><![CDATA[SCRUM]]></category>

		<guid isPermaLink="false">http://softwareramblings.com/?p=245</guid>
		<description><![CDATA[scrumbut [skruhmbut] noun.
1. A person engaged in only partial Agile project management or development methodologies
2. One who engages in either semi-agile or quasi-waterfall development methodologies.
3. One who adopts only SOME tenants of the SCRUM methodology.
4. In general, one who uses the word &#8220;but&#8221; when answering the question &#8220;Do you do SCRUM?&#8221;
ScrumButs are the best part of [...]]]></description>
			<content:encoded><![CDATA[<p><strong>scrumbut </strong><em>[skruhmbut]</em> noun.<br />
<span>1. A person engaged in only partial Agile project management or development methodologies<br />
2. One who engages in either semi-agile or quasi-waterfall development methodologies.<br />
3. <strong>One who adopts only SOME tenants of the SCRUM methodology</strong>.<br />
4. In general, one who uses the word &#8220;but&#8221; when answering the question &#8220;Do you do SCRUM?&#8221;</span></p>
<p><a href="http://feedproxy.google.com/~r/noop/~3/c2tAs-3r7tU/scrumbuts-are-the-best-part-of-scrum.html">ScrumButs are the best part of SCRUM</a> makes a great argument that &#8220;<strong>optimal behavior of a team cannot be predicted</strong>&#8221; and so retrospectives may be used to tweak SCRUM to optimize it for a particular team. At last a refreshing break from the SCRUM zealots who believe that any deviation from SCRUM is bad and that if you are not doing pure SCRUM then you are not doing SCRUM.</p>
<p>It is worth highlighting that there is a great emphasis on using <strong>retrospectives </strong>to drive positive optimizations. Pure SCRUM should be adhered to for an iteration or two and then use retrospectives to adjust as necessary for a particular team. The need for an adjustment highlights an aspect of the team behavior that may be different from that envisaged by SCRUM. The team should decide if that behavior is good and should be kept (via a ScrumBut) or if the behavior is bad and if the team should think about a change. Either way the focus is on optimizing the team behavior and this is usually good.</p>
<p align="left"><a class="tt" href="http://twitter.com/home/?status=ScrumButs+http://zqbkg.th8.us" title="Post to Twitter"><img class="nothumb" src="http://softwareramblings.com/wp-content/plugins/tweet-this/icons/tt-twitter.png" alt="Post to Twitter" /></a> <a class="tt" href="http://twitter.com/home/?status=ScrumButs+http://zqbkg.th8.us" title="Post to Twitter">Tweet This Post</a> <a class="tt" href="http://digg.com/submit?url=http://softwareramblings.com/2009/09/scrumbuts.html&amp;title=ScrumButs" title="Post to Digg"><img class="nothumb" src="http://softwareramblings.com/wp-content/plugins/tweet-this/icons/tt-digg.png" alt="Post to Digg" /></a> <a class="tt" href="http://digg.com/submit?url=http://softwareramblings.com/2009/09/scrumbuts.html&amp;title=ScrumButs" title="Post to Digg">Digg This Post</a> <a class="tt" href="http://reddit.com/submit?url=http://softwareramblings.com/2009/09/scrumbuts.html&amp;title=ScrumButs" title="Post to Reddit"><img class="nothumb" src="http://softwareramblings.com/wp-content/plugins/tweet-this/icons/tt-reddit.png" alt="Post to Reddit" /></a> <a class="tt" href="http://reddit.com/submit?url=http://softwareramblings.com/2009/09/scrumbuts.html&amp;title=ScrumButs" title="Post to Reddit">Reddit</a> <a class="tt" href="http://stumbleupon.com/submit?url=http://softwareramblings.com/2009/09/scrumbuts.html&amp;title=ScrumButs" title="Post to StumbleUpon"><img class="nothumb" src="http://softwareramblings.com/wp-content/plugins/tweet-this/icons/tt-su.png" alt="Post to StumbleUpon" /></a> <a class="tt" href="http://stumbleupon.com/submit?url=http://softwareramblings.com/2009/09/scrumbuts.html&amp;title=ScrumButs" title="Post to StumbleUpon">Stumble This Post</a></p><img src="http://feeds.feedburner.com/~r/SoftwareRamblings/~4/AdFgh9lf2os" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://softwareramblings.com/2009/09/scrumbuts.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://softwareramblings.com/2009/09/scrumbuts.html</feedburner:origLink></item>
		<item>
		<title>Why I like Ruby …</title>
		<link>http://feedproxy.google.com/~r/SoftwareRamblings/~3/xWVKmNM-brg/why-i-like-ruby.html</link>
		<comments>http://softwareramblings.com/2009/08/why-i-like-ruby.html#comments</comments>
		<pubDate>Wed, 19 Aug 2009 10:16:42 +0000</pubDate>
		<dc:creator>Stephen Doyle</dc:creator>
				<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://softwareramblings.com/?p=241</guid>
		<description><![CDATA[
2.times { deck.shuffle }

is much more expressive than
for(i=0; i]]></description>
			<content:encoded><![CDATA[<pre class="brush: ruby;">
2.times { deck.shuffle }
</pre>
<p>is much more expressive than</p>
<p>for(i=0; i<2; ++i)<br />
    deck.shuffle</p>
<p align="left"><a class="tt" href="http://twitter.com/home/?status=Why+I+like+Ruby+%26%238230%3B+http://d76y3.th8.us" title="Post to Twitter"><img class="nothumb" src="http://softwareramblings.com/wp-content/plugins/tweet-this/icons/tt-twitter.png" alt="Post to Twitter" /></a> <a class="tt" href="http://twitter.com/home/?status=Why+I+like+Ruby+%26%238230%3B+http://d76y3.th8.us" title="Post to Twitter">Tweet This Post</a> <a class="tt" href="http://digg.com/submit?url=http://softwareramblings.com/2009/08/why-i-like-ruby.html&amp;title=Why+I+like+Ruby+%26%238230%3B" title="Post to Digg"><img class="nothumb" src="http://softwareramblings.com/wp-content/plugins/tweet-this/icons/tt-digg.png" alt="Post to Digg" /></a> <a class="tt" href="http://digg.com/submit?url=http://softwareramblings.com/2009/08/why-i-like-ruby.html&amp;title=Why+I+like+Ruby+%26%238230%3B" title="Post to Digg">Digg This Post</a> <a class="tt" href="http://reddit.com/submit?url=http://softwareramblings.com/2009/08/why-i-like-ruby.html&amp;title=Why+I+like+Ruby+%26%238230%3B" title="Post to Reddit"><img class="nothumb" src="http://softwareramblings.com/wp-content/plugins/tweet-this/icons/tt-reddit.png" alt="Post to Reddit" /></a> <a class="tt" href="http://reddit.com/submit?url=http://softwareramblings.com/2009/08/why-i-like-ruby.html&amp;title=Why+I+like+Ruby+%26%238230%3B" title="Post to Reddit">Reddit</a> <a class="tt" href="http://stumbleupon.com/submit?url=http://softwareramblings.com/2009/08/why-i-like-ruby.html&amp;title=Why+I+like+Ruby+%26%238230%3B" title="Post to StumbleUpon"><img class="nothumb" src="http://softwareramblings.com/wp-content/plugins/tweet-this/icons/tt-su.png" alt="Post to StumbleUpon" /></a> <a class="tt" href="http://stumbleupon.com/submit?url=http://softwareramblings.com/2009/08/why-i-like-ruby.html&amp;title=Why+I+like+Ruby+%26%238230%3B" title="Post to StumbleUpon">Stumble This Post</a></p><img src="http://feeds.feedburner.com/~r/SoftwareRamblings/~4/xWVKmNM-brg" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://softwareramblings.com/2009/08/why-i-like-ruby.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://softwareramblings.com/2009/08/why-i-like-ruby.html</feedburner:origLink></item>
		<item>
		<title>Hindsight and the 80/20 rule</title>
		<link>http://feedproxy.google.com/~r/SoftwareRamblings/~3/MVFqHoLHEmo/hindsight-and-the-8020-rule.html</link>
		<comments>http://softwareramblings.com/2009/07/hindsight-and-the-8020-rule.html#comments</comments>
		<pubDate>Fri, 31 Jul 2009 21:58:34 +0000</pubDate>
		<dc:creator>Stephen Doyle</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://softwareramblings.com/?p=235</guid>
		<description><![CDATA[Good perspective on the 80/20 rule and the obvious benefit of hindsight!
It’s easy to be cynical about the 80/20 rule. There are too many hucksters selling books and consulting services that boil down to saying “concentrate on what’s most productive.” Thanks. Never would have thought of that. Let me write you a check.
At one extreme [...]]]></description>
			<content:encoded><![CDATA[<p>Good perspective on the 80/20 rule and the obvious benefit of hindsight!</p>
<blockquote><p style="margin-top: 0px; margin-right: 0px; margin-left: 0px; margin-bottom: 1.667em; padding: 0px;">It’s easy to be cynical about the 80/20 rule. There are too many hucksters selling books and consulting services that boil down to saying “concentrate on what’s most productive.” Thanks. Never would have thought of that. Let me write you a check.</p>
<p style="margin-top: 0px; margin-right: 0px; margin-left: 0px; margin-bottom: 1.667em; padding: 0px;">At one extreme is the belief that everything is equally important, or at least equally likely to be important. At the other extreme is the belief that 80/20 principles are everywhere an that it is possible to predict the “20″ part. Reality lies somewhere between these extremes, but I believe it is often closer to the latter than we think. In many circumstances acting as if everything were equally important is idiocy or <a style="color: #2361a1; text-decoration: underline; padding: 0px; margin: 0px;" href="http://www.johndcook.com/blog/2009/06/17/sloth/">sloth</a>.</p>
<p style="margin-top: 0px; margin-right: 0px; margin-left: 0px; margin-bottom: 1.667em; padding: 0px;">You can improve your chances of correctly guessing which activities are going to be most productive. Nobody is going to write a book that tells you how to do this in your particular circumstances. It takes experience and hard work. But you can get better at it over time.</p>
</blockquote>
<p><a href="http://www.johndcook.com/blog/2009/07/29/can-you-predict-the-20-in-8020/">Can you predict the &#8220;20&#8243; in 80/20?</a></p>
<p align="left"><a class="tt" href="http://twitter.com/home/?status=Hindsight+and+the+80%2F20+rule+http://zkon6.th8.us" title="Post to Twitter"><img class="nothumb" src="http://softwareramblings.com/wp-content/plugins/tweet-this/icons/tt-twitter.png" alt="Post to Twitter" /></a> <a class="tt" href="http://twitter.com/home/?status=Hindsight+and+the+80%2F20+rule+http://zkon6.th8.us" title="Post to Twitter">Tweet This Post</a> <a class="tt" href="http://digg.com/submit?url=http://softwareramblings.com/2009/07/hindsight-and-the-8020-rule.html&amp;title=Hindsight+and+the+80%2F20+rule" title="Post to Digg"><img class="nothumb" src="http://softwareramblings.com/wp-content/plugins/tweet-this/icons/tt-digg.png" alt="Post to Digg" /></a> <a class="tt" href="http://digg.com/submit?url=http://softwareramblings.com/2009/07/hindsight-and-the-8020-rule.html&amp;title=Hindsight+and+the+80%2F20+rule" title="Post to Digg">Digg This Post</a> <a class="tt" href="http://reddit.com/submit?url=http://softwareramblings.com/2009/07/hindsight-and-the-8020-rule.html&amp;title=Hindsight+and+the+80%2F20+rule" title="Post to Reddit"><img class="nothumb" src="http://softwareramblings.com/wp-content/plugins/tweet-this/icons/tt-reddit.png" alt="Post to Reddit" /></a> <a class="tt" href="http://reddit.com/submit?url=http://softwareramblings.com/2009/07/hindsight-and-the-8020-rule.html&amp;title=Hindsight+and+the+80%2F20+rule" title="Post to Reddit">Reddit</a> <a class="tt" href="http://stumbleupon.com/submit?url=http://softwareramblings.com/2009/07/hindsight-and-the-8020-rule.html&amp;title=Hindsight+and+the+80%2F20+rule" title="Post to StumbleUpon"><img class="nothumb" src="http://softwareramblings.com/wp-content/plugins/tweet-this/icons/tt-su.png" alt="Post to StumbleUpon" /></a> <a class="tt" href="http://stumbleupon.com/submit?url=http://softwareramblings.com/2009/07/hindsight-and-the-8020-rule.html&amp;title=Hindsight+and+the+80%2F20+rule" title="Post to StumbleUpon">Stumble This Post</a></p><img src="http://feeds.feedburner.com/~r/SoftwareRamblings/~4/MVFqHoLHEmo" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://softwareramblings.com/2009/07/hindsight-and-the-8020-rule.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://softwareramblings.com/2009/07/hindsight-and-the-8020-rule.html</feedburner:origLink></item>
		<item>
		<title>Update: STL vs Gnulib Performance</title>
		<link>http://feedproxy.google.com/~r/SoftwareRamblings/~3/SuFJMwUHXf8/update-stl-vs-gnulib-performance.html</link>
		<comments>http://softwareramblings.com/2009/06/update-stl-vs-gnulib-performance.html#comments</comments>
		<pubDate>Sun, 28 Jun 2009 00:00:08 +0000</pubDate>
		<dc:creator>Stephen Doyle</dc:creator>
				<category><![CDATA[C++]]></category>
		<category><![CDATA[STL]]></category>

		<guid isPermaLink="false">http://softwareramblings.com/?p=222</guid>
		<description><![CDATA[Following up on a previous post about the relative performance of STL vs gnulib, this post extends and completes the analysis to include the stl::vector and stl::deque containers. These containers provide a more direct comparison against the Gnulib array-list and carray-list implementations. The results are shown below. Please refer to the previous post on this [...]]]></description>
			<content:encoded><![CDATA[<p>Following up on a <a href="http://softwareramblings.com/2009/06/stl-vs-gnulib-performance.html">previous post</a> about the relative performance of STL vs <a href="http://www.gnu.org/software/gnulib/">gnulib</a>, this post extends and completes the analysis to include the stl::vector and stl::deque containers. These containers provide a more direct comparison against the Gnulib array-list and carray-list implementations. The results are shown below. Please refer to the <a href="http://softwareramblings.com/2009/06/stl-vs-gnulib-performance.html">previous post</a> on this subject for details on how the results were collected including source code.</p>
<p>DISCLAIMER: Please note that the intent of the post is not to suggest that gnulib should be used instead of STL in C++ programs, but rather to point out that although not part of the C language specification, gnulib offers C programmers a set of containers whose performance is comparable to the STL container performance available to C++ programmers.</p>
<div id="attachment_224" class="wp-caption alignnone" style="width: 395px"></p>
<div class="mceTemp">
<dl id="attachment_228" class="wp-caption alignnone" style="width: 395px;">
<dt class="wp-caption-dt"><a href="http://softwareramblings.com/wp-content/uploads/2009/06/container_push_back_perf.jpg"><img class="size-full wp-image-228  " title="container_push_back_perf" src="http://softwareramblings.com/wp-content/uploads/2009/06/container_push_back_perf.jpg" alt="Push back (insert at end) performance" width="385" height="235" /></a><p class="wp-caption-text">Push back (insert at end) performance</p></div>
<p><a href="http://softwareramblings.com/wp-content/uploads/2009/06/container_search_perf.jpg"><img class="size-full wp-image-224   " title="container_search_perf" src="http://softwareramblings.com/wp-content/uploads/2009/06/container_search_perf.jpg" alt="Search Performance" width="383" height="230" /></a></dt>
<dd class="wp-caption-dd">Search (unsorted) Performance</dd>
</dl>
</div>
<p>Note that the vertical axis represents seconds and the lower the bar for each algorithm, the better.</p>
<p>Based on the above results, it can be seen that the performance of the stl::list is comparable to the gnulib linked_list for both insertions (at the end) and unsorted searching. Gnulib array_list is comparable in implementation to the stl::vector but proves to be almost 2x faster for insertions and ~1.5x slower for searching for this test. The stl::deque is also comparable to the gnulib array_list and proves to be slightly faster for insertions and just under 3x slower for searching.</p>
<p>As a final note, this analysis only performed comparisons based on two tests &#8211; push back and unsorted find. This is just an indication of performance and far from complete. The results may well be different if different tests were chosen.</p>
<p align="left"><a class="tt" href="http://twitter.com/home/?status=Update%3A+STL+vs+Gnulib+Performance+http://zrfp5.th8.us" title="Post to Twitter"><img class="nothumb" src="http://softwareramblings.com/wp-content/plugins/tweet-this/icons/tt-twitter.png" alt="Post to Twitter" /></a> <a class="tt" href="http://twitter.com/home/?status=Update%3A+STL+vs+Gnulib+Performance+http://zrfp5.th8.us" title="Post to Twitter">Tweet This Post</a> <a class="tt" href="http://digg.com/submit?url=http://softwareramblings.com/2009/06/update-stl-vs-gnulib-performance.html&amp;title=Update%3A+STL+vs+Gnulib+Performance" title="Post to Digg"><img class="nothumb" src="http://softwareramblings.com/wp-content/plugins/tweet-this/icons/tt-digg.png" alt="Post to Digg" /></a> <a class="tt" href="http://digg.com/submit?url=http://softwareramblings.com/2009/06/update-stl-vs-gnulib-performance.html&amp;title=Update%3A+STL+vs+Gnulib+Performance" title="Post to Digg">Digg This Post</a> <a class="tt" href="http://reddit.com/submit?url=http://softwareramblings.com/2009/06/update-stl-vs-gnulib-performance.html&amp;title=Update%3A+STL+vs+Gnulib+Performance" title="Post to Reddit"><img class="nothumb" src="http://softwareramblings.com/wp-content/plugins/tweet-this/icons/tt-reddit.png" alt="Post to Reddit" /></a> <a class="tt" href="http://reddit.com/submit?url=http://softwareramblings.com/2009/06/update-stl-vs-gnulib-performance.html&amp;title=Update%3A+STL+vs+Gnulib+Performance" title="Post to Reddit">Reddit</a> <a class="tt" href="http://stumbleupon.com/submit?url=http://softwareramblings.com/2009/06/update-stl-vs-gnulib-performance.html&amp;title=Update%3A+STL+vs+Gnulib+Performance" title="Post to StumbleUpon"><img class="nothumb" src="http://softwareramblings.com/wp-content/plugins/tweet-this/icons/tt-su.png" alt="Post to StumbleUpon" /></a> <a class="tt" href="http://stumbleupon.com/submit?url=http://softwareramblings.com/2009/06/update-stl-vs-gnulib-performance.html&amp;title=Update%3A+STL+vs+Gnulib+Performance" title="Post to StumbleUpon">Stumble This Post</a></p><img src="http://feeds.feedburner.com/~r/SoftwareRamblings/~4/SuFJMwUHXf8" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://softwareramblings.com/2009/06/update-stl-vs-gnulib-performance.html/feed</wfw:commentRss>
		<slash:comments>6</slash:comments>
		<feedburner:origLink>http://softwareramblings.com/2009/06/update-stl-vs-gnulib-performance.html</feedburner:origLink></item>
	</channel>
</rss>
