<?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>Floorplanner Tech Blog &#187; request-log-analyzer</title>
	<atom:link href="http://techblog.floorplanner.com/tag/request-log-analyzer/feed/" rel="self" type="application/rss+xml" />
	<link>http://techblog.floorplanner.com</link>
	<description>Just another WordPress weblog</description>
	<lastBuildDate>Thu, 19 Nov 2009 04:00:57 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Request-log-analyzer 1.5.0</title>
		<link>http://techblog.floorplanner.com/2009/11/18/request-log-analyzer-1-5-0/</link>
		<comments>http://techblog.floorplanner.com/2009/11/18/request-log-analyzer-1-5-0/#comments</comments>
		<pubDate>Wed, 18 Nov 2009 17:51:42 +0000</pubDate>
		<dc:creator>Willem van Bergen</dc:creator>
				<category><![CDATA[Databases]]></category>
		<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[request-log-analyzer]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[slow query log]]></category>

		<guid isPermaLink="false">http://techblog.floorplanner.com/?p=801</guid>
		<description><![CDATA[Bart and I just released request-log-analyzer version 1.5.0. New features include:

MySQL slow query log format support to analyze what queries are slowing down your database.
Format autodetection: with all those supported file formats, remembering the right --format parameter gets tricky. With format autodetection, this usually is not needed anymore!

As always, run the following command to install [...]]]></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%2Ftechblog.floorplanner.com%2F2009%2F11%2F18%2Frequest-log-analyzer-1-5-0%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Ftechblog.floorplanner.com%2F2009%2F11%2F18%2Frequest-log-analyzer-1-5-0%2F" height="61" width="51" /></a></div><p>Bart and I just released <a href="http://github.com/wvanbergen/request-log-analyzer">request-log-analyzer</a> version 1.5.0. New features include:</p>
<ul>
<li><a href="http://wiki.github.com/wvanbergen/request-log-analyzer/mysql-slow-query-log">MySQL slow query log</a> format support to analyze what queries are slowing down your database.</li>
<li><strong>Format autodetection:</strong> with all those supported file formats, remembering the right <code style="white-space: nowrap">--format</code> parameter gets tricky. With format autodetection, this usually is not needed anymore!</li>
</ul>
<p>As always, run the following command to install or upgrade to the latest version:</p>

<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family: Monaco,monospace;">$ gem install request-log-analyzer</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://techblog.floorplanner.com/2009/11/18/request-log-analyzer-1-5-0/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Request-log-analyzer 1.4.0</title>
		<link>http://techblog.floorplanner.com/2009/09/30/request-log-analyzer-1-4-0/</link>
		<comments>http://techblog.floorplanner.com/2009/09/30/request-log-analyzer-1-4-0/#comments</comments>
		<pubDate>Wed, 30 Sep 2009 09:40:04 +0000</pubDate>
		<dc:creator>Willem van Bergen</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Amazon S3]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[log analysis]]></category>
		<category><![CDATA[merb]]></category>
		<category><![CDATA[profiling]]></category>
		<category><![CDATA[Rack CommonLogger]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[request-log-analyzer]]></category>

		<guid isPermaLink="false">http://techblog.floorplanner.com/?p=729</guid>
		<description><![CDATA[Bart and I have been working a lot on request-log-analyzer lately, our tool to produce performance reports for web applications based on their log files. Today, we released version 1.4.0, which boasts many new features since I last blogged about a release. The changelog contains all changes we have implemented recently with some additional information, [...]]]></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%2Ftechblog.floorplanner.com%2F2009%2F09%2F30%2Frequest-log-analyzer-1-4-0%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Ftechblog.floorplanner.com%2F2009%2F09%2F30%2Frequest-log-analyzer-1-4-0%2F" height="61" width="51" /></a></div><p>Bart and I have been working a lot on <a href="http://github.com/wvanbergen/request-log-analyzer">request-log-analyzer</a> lately, our tool to produce performance reports for web applications based on their log files. Today, we released version 1.4.0, which boasts many new features since I last blogged about a release. The <a href="http://wiki.github.com/wvanbergen/request-log-analyzer/changelog">changelog</a> contains all changes we have implemented recently with some additional information, but these are the highlights:</p>
<ul>
<li><strong>New and improved log formats:</strong> r-l-a can now handle <a href="http://wiki.github.com/wvanbergen/request-log-analyzer/apache-access-log">Apache access logs</a>, <a href="http://wiki.github.com/wvanbergen/request-log-analyzer/apache-access-log#rack">Rack CommonLogger logs</a> and <a href="http://wiki.github.com/wvanbergen/request-log-analyzer/amazon-s3-access-log">Amazon S3 access logs</a>. Moreover, the Rails format has been restructured to offer <a href="http://wiki.github.com/wvanbergen/request-log-analyzer/rails-request-log">more flexibility</a>.</li>
<li><strong>Improved database support: </strong>the database supports other databases than SQLite3 as well, and r-l-a can append information to an existing database instead of overwriting it. Moreover, a console tool similar to Rails&#8217;s script/console is bundled to inspect the database and run queries on it easily.</li>
<li><strong>Added standard deviation to reports: </strong>the standard deviation measure has been added to duration and traffic reports to get some feel of the variation in values besides the mean.</li>
<li><strong>E-mailing reports:</strong> r-l-a can email the performance report to a given e-mail address. This can be useful when running r-l-a in a cron job.</li>
<li><strong>Compressed log support:</strong> r-l-a will decompress compressed logs automatically.</li>
<li><strong>Speed improvements:</strong> we have profiled <a href="http://techblog.floorplanner.com/2009/09/27/performance-tweaking-of-ruby-algorithms/">request-log-analyzer itself</a> and significantly improved its performance.</li>
<li><strong>API:</strong> we created a basic API so it is possible to use the r-l-a engine as a library as well.</li>
<li><strong>Monitoring integration:</strong> integrate performance information into your <a href="http://github.com/barttenbrinke/munin-plugins-rails/">Munin dashboard</a> or your <a href="http://wiki.github.com/wvanbergen/request-log-analyzer/scout">Scout account</a>.</li>
</ul>
<p>As always, use <code>sudo gem install request-log-analyzer</code> to install or upgrade.</p>
<h3>Ruby en Rails 2009 conference</h3>
<p>Bart and I will be presenting request-log-analyzer and performance tuning of Rails applications in general at the <a href="http://2009.rubyenrails.nl">Ruby en Rails</a> conference in Amsterdam, October 30-31 2009. We hope to see you there!</p>
]]></content:encoded>
			<wfw:commentRss>http://techblog.floorplanner.com/2009/09/30/request-log-analyzer-1-4-0/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Performance tweaking of Ruby algorithms</title>
		<link>http://techblog.floorplanner.com/2009/09/27/performance-tweaking-of-ruby-algorithms/</link>
		<comments>http://techblog.floorplanner.com/2009/09/27/performance-tweaking-of-ruby-algorithms/#comments</comments>
		<pubDate>Sun, 27 Sep 2009 06:02:42 +0000</pubDate>
		<dc:creator>Willem van Bergen</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[algorithms]]></category>
		<category><![CDATA[analysis]]></category>
		<category><![CDATA[blocks]]></category>
		<category><![CDATA[parallelization]]></category>
		<category><![CDATA[performance]]></category>
		<category><![CDATA[profiling]]></category>
		<category><![CDATA[regular expressions]]></category>
		<category><![CDATA[request-log-analyzer]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[ruby-prof]]></category>

		<guid isPermaLink="false">http://techblog.floorplanner.com/?p=716</guid>
		<description><![CDATA[I have been working on request-log-analyzer quite a lot recently. One of the things I focused on was improving the parsing performance: because it parses log files that often are very big, processing times tend to be long. So all savings are very welcome.
Improving the performance of a command line application that does a lot [...]]]></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%2Ftechblog.floorplanner.com%2F2009%2F09%2F27%2Fperformance-tweaking-of-ruby-algorithms%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Ftechblog.floorplanner.com%2F2009%2F09%2F27%2Fperformance-tweaking-of-ruby-algorithms%2F" height="61" width="51" /></a></div><p>I have been working on <a href="http://github.com/wvanbergen/request-log-analyzer">request-log-analyzer</a> quite a lot recently. One of the things I focused on was improving the parsing performance: because it parses log files that often are very big, processing times tend to be long. So all savings are very welcome.</p>
<p>Improving the performance of a command line application that does a lot of processing is very different from optimizing the performance of a web application. Request-log-analyzer basically reads a file line by line and processes it, so small performance improvements in the line processing algorithm can really add up when the file has a lot of lines. I used <a href="http://ruby-prof.rubyforge.org/">ruby-prof</a> to get information about the performance of our algorithms split out by method to focus my tweaking efforts. I have written down some of my findings below; hopefully they can be helpful.</p>
<h3>Parallelization</h3>
<p>My first thought for improving performance was parallelization: parse multiple lines at the same time. Unfortunately, this did not yield the results I was hoping for: it instead become slower. Probably, this is because Ruby implements its own in-process threading and thus only uses one core of my processor.</p>
<h3>Block overhead</h3>
<p>The overhead of using a block should not be underestimated. Consider the following simple change, which improved the performance of request-log-analyzer by 1.5-2% on large log files:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family: Monaco,monospace;"><span style="color:#008000; font-style:italic;"># with block</span>
io.<span style="color:#9900CC;">each_line</span> <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#006600; font-weight:bold;">|</span>line<span style="color:#006600; font-weight:bold;">|</span> process_line<span style="color:#006600; font-weight:bold;">&#40;</span>line<span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#125;</span>
&nbsp;
<span style="color:#008000; font-style:italic;"># without block</span>
process_line<span style="color:#006600; font-weight:bold;">&#40;</span>line<span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#9966CC; font-weight:bold;">while</span> line = io.<span style="color:#CC0066; font-weight:bold;">gets</span></pre></div></div>

<h3>Regular expressions</h3>
<p>If you&#8217;re using complex regular expressions, and you do not expect that every string will match it successfully, it can be beneficial to test the string with a simpler regexp first. For example, request-log-analyzer uses a complex regexp to see if a line in a log file is a &#8220;Completed in&#8230;&#8221; line with the request duration in it:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family: Monaco,monospace;"><span style="color:#008000; font-style:italic;"># Check every line to see if it is a &quot;completed&quot; line and capture the values</span>
<span style="color:#9966CC; font-weight:bold;">if</span> line =~ <span style="color:#006600; font-weight:bold;">/</span>Completed <span style="color:#9966CC; font-weight:bold;">in</span> <span style="color:#006600; font-weight:bold;">&#40;</span>\d<span style="color:#006600; font-weight:bold;">+</span><span style="color:#006600; font-weight:bold;">&#41;</span>ms \<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#40;</span>?:View: <span style="color:#006600; font-weight:bold;">&#40;</span>\d<span style="color:#006600; font-weight:bold;">+</span><span style="color:#006600; font-weight:bold;">&#41;</span>, <span style="color:#006600; font-weight:bold;">&#41;</span>?DB: <span style="color:#006600; font-weight:bold;">&#40;</span>\d<span style="color:#006600; font-weight:bold;">+</span><span style="color:#006600; font-weight:bold;">&#41;</span>\<span style="color:#006600; font-weight:bold;">&#41;</span> \<span style="color:#006600; font-weight:bold;">|</span> <span style="color:#006600; font-weight:bold;">&#40;</span>\d\d\d<span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#006600; font-weight:bold;">+</span>\<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006600; font-weight:bold;">&#40;</span>http.<span style="color:#006600; font-weight:bold;">+</span><span style="color:#006600; font-weight:bold;">&#41;</span>\<span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">/</span>
  <span style="color:#008000; font-style:italic;"># do something with the captured values</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p>I improved this by first checking for a superficial regexp that tells me with 99% certainty that the complex regexp will match the line successfully as well:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family: Monaco,monospace;"><span style="color:#9966CC; font-weight:bold;">if</span> line =~ <span style="color:#006600; font-weight:bold;">/</span>Completed <span style="color:#9966CC; font-weight:bold;">in</span><span style="color:#006600; font-weight:bold;">/</span>
  <span style="color:#9966CC; font-weight:bold;">if</span> line =~ <span style="color:#006600; font-weight:bold;">/</span>Completed <span style="color:#9966CC; font-weight:bold;">in</span> <span style="color:#006600; font-weight:bold;">&#40;</span>\d<span style="color:#006600; font-weight:bold;">+</span><span style="color:#006600; font-weight:bold;">&#41;</span>ms \<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#40;</span>?:View: <span style="color:#006600; font-weight:bold;">&#40;</span>\d<span style="color:#006600; font-weight:bold;">+</span><span style="color:#006600; font-weight:bold;">&#41;</span>, <span style="color:#006600; font-weight:bold;">&#41;</span>?DB: <span style="color:#006600; font-weight:bold;">&#40;</span>\d<span style="color:#006600; font-weight:bold;">+</span><span style="color:#006600; font-weight:bold;">&#41;</span>\<span style="color:#006600; font-weight:bold;">&#41;</span> \<span style="color:#006600; font-weight:bold;">|</span> <span style="color:#006600; font-weight:bold;">&#40;</span>\d\d\d<span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#006600; font-weight:bold;">+</span>\<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006600; font-weight:bold;">&#40;</span>http.<span style="color:#006600; font-weight:bold;">+</span><span style="color:#006600; font-weight:bold;">&#41;</span>\<span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">/</span>
    <span style="color:#008000; font-style:italic;"># do something with the captured values</span>
  <span style="color:#9966CC; font-weight:bold;">else</span>
    <span style="color:#ff6633; font-weight:bold;">$stderr</span>.<span style="color:#CC0066; font-weight:bold;">puts</span> <span style="color:#996600;">&quot;#{line.inspect} expected to match 'Completed' regexp!&quot;</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p>Depending on the log file, this can increase performance by ~3%. Another benefit of this approach is that it will give feedback on lines that matched the simple regexp, but not the complex one. This information can be used to correct the regular expressions.</p>
<h3>Calculate things that do not change only once</h3>
<p>Calculate things that do not change only once is easier said than done. For instance, request-log analyzer can aggregate durations in a category. A category can be based on a request field that is parsed from the log, or a <code>Proc</code> that calculates it:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family: Monaco,monospace;"><span style="color:#008000; font-style:italic;"># during parsing:</span>
<span style="color:#9966CC; font-weight:bold;">if</span> categorizer.<span style="color:#9900CC;">respond_to</span>?<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:call</span><span style="color:#006600; font-weight:bold;">&#41;</span>
  category = categorizer.<span style="color:#9900CC;">call</span><span style="color:#006600; font-weight:bold;">&#40;</span>request<span style="color:#006600; font-weight:bold;">&#41;</span>
<span style="color:#9966CC; font-weight:bold;">else</span>
  category = request<span style="color:#006600; font-weight:bold;">&#91;</span>categorizer<span style="color:#006600; font-weight:bold;">&#93;</span>
<span style="color:#9966CC; font-weight:bold;">end</span>
categories<span style="color:#006600; font-weight:bold;">&#91;</span>category<span style="color:#006600; font-weight:bold;">&#93;</span>.<span style="color:#9900CC;">aggregate_request</span><span style="color:#006600; font-weight:bold;">&#40;</span>request<span style="color:#006600; font-weight:bold;">&#41;</span></pre></div></div>

<p>With this implementation, <code>categorizer</code> will be checked to be a <code>Proc</code> for every request, but as the value of <code>categorizer</code> will not change, the result of the check will be constant as well. I solved this my making sure that it is always a <code>Proc</code> beforehand, so the check is no longer necessary during parsing:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family: Monaco,monospace;"><span style="color:#008000; font-style:italic;"># before parsing:</span>
<span style="color:#9966CC; font-weight:bold;">if</span> categorizer.<span style="color:#9900CC;">respond_to</span>?<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:call</span><span style="color:#006600; font-weight:bold;">&#41;</span>
  categorizer_proc = categorizer
<span style="color:#9966CC; font-weight:bold;">else</span>
  categorizer_proc = <span style="color:#CC0066; font-weight:bold;">lambda</span> <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#006600; font-weight:bold;">|</span>request<span style="color:#006600; font-weight:bold;">|</span> request<span style="color:#006600; font-weight:bold;">&#91;</span>categorizer<span style="color:#006600; font-weight:bold;">&#93;</span> <span style="color:#006600; font-weight:bold;">&#125;</span>
<span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
<span style="color:#008000; font-style:italic;"># during parsing:</span>
category = categorizer_proc.<span style="color:#9900CC;">call</span><span style="color:#006600; font-weight:bold;">&#40;</span>request<span style="color:#006600; font-weight:bold;">&#41;</span>
categories<span style="color:#006600; font-weight:bold;">&#91;</span>category<span style="color:#006600; font-weight:bold;">&#93;</span>.<span style="color:#9900CC;">aggregate_request</span><span style="color:#006600; font-weight:bold;">&#40;</span>request<span style="color:#006600; font-weight:bold;">&#41;</span></pre></div></div>

<p>Performance gain: ~1%! And because on several instances a similar technique could be applied, the performance got improved by about 4% in total.</p>
<h3>Check the most common case first</h3>
<p>Consider the following example, which converts a number in any traffic unit (kilobytes, MB, etc) to bytes:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family: Monaco,monospace;"><span style="color:#9966CC; font-weight:bold;">def</span> convert_traffic<span style="color:#006600; font-weight:bold;">&#40;</span>value, unit<span style="color:#006600; font-weight:bold;">&#41;</span>
  <span style="color:#9966CC; font-weight:bold;">case</span> unit
  <span style="color:#9966CC; font-weight:bold;">when</span> <span style="color:#ff3333; font-weight:bold;">:GB</span>, <span style="color:#ff3333; font-weight:bold;">:G</span>, <span style="color:#ff3333; font-weight:bold;">:gigabyte</span>      <span style="color:#9966CC; font-weight:bold;">then</span> <span style="color:#006600; font-weight:bold;">&#40;</span>value.<span style="color:#9900CC;">to_f</span> <span style="color:#006600; font-weight:bold;">*</span> <span style="color:#006666;">1000</span>_000_000<span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#9900CC;">round</span>
  <span style="color:#9966CC; font-weight:bold;">when</span> <span style="color:#ff3333; font-weight:bold;">:MB</span>, <span style="color:#ff3333; font-weight:bold;">:M</span>, <span style="color:#ff3333; font-weight:bold;">:megabyte</span>      <span style="color:#9966CC; font-weight:bold;">then</span> <span style="color:#006600; font-weight:bold;">&#40;</span>value.<span style="color:#9900CC;">to_f</span> <span style="color:#006600; font-weight:bold;">*</span> <span style="color:#006666;">1000</span>_000<span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#9900CC;">round</span>
  <span style="color:#9966CC; font-weight:bold;">when</span> <span style="color:#ff3333; font-weight:bold;">:KB</span>, <span style="color:#ff3333; font-weight:bold;">:K</span>, <span style="color:#ff3333; font-weight:bold;">:kilobyte</span>, <span style="color:#ff3333; font-weight:bold;">:kB</span> <span style="color:#9966CC; font-weight:bold;">then</span> <span style="color:#006600; font-weight:bold;">&#40;</span>value.<span style="color:#9900CC;">to_f</span> <span style="color:#006600; font-weight:bold;">*</span> <span style="color:#006666;">1000</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#9900CC;">round</span>
  <span style="color:#008000; font-style:italic;"># ... even more units here</span>
  <span style="color:#9966CC; font-weight:bold;">else</span> value.<span style="color:#9900CC;">to_i</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p>In most cases, the value will simply given in bytes, which will be returned by the final <code>else</code> after all possibilities have been checked. This can be improved by checking for this possibility first:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family: Monaco,monospace;"><span style="color:#008000; font-style:italic;"># Converts traffic in any unit to bytes.</span>
<span style="color:#9966CC; font-weight:bold;">def</span> convert_traffic<span style="color:#006600; font-weight:bold;">&#40;</span>value, unit<span style="color:#006600; font-weight:bold;">&#41;</span>
  <span style="color:#9966CC; font-weight:bold;">case</span> unit
  <span style="color:#9966CC; font-weight:bold;">when</span> <span style="color:#0000FF; font-weight:bold;">nil</span>, <span style="color:#ff3333; font-weight:bold;">:B</span>, <span style="color:#ff3333; font-weight:bold;">:byte</span>          <span style="color:#9966CC; font-weight:bold;">then</span> value.<span style="color:#9900CC;">to_i</span>
  <span style="color:#9966CC; font-weight:bold;">when</span> <span style="color:#ff3333; font-weight:bold;">:GB</span>, <span style="color:#ff3333; font-weight:bold;">:G</span>, <span style="color:#ff3333; font-weight:bold;">:gigabyte</span>      <span style="color:#9966CC; font-weight:bold;">then</span> <span style="color:#006600; font-weight:bold;">&#40;</span>value.<span style="color:#9900CC;">to_f</span> <span style="color:#006600; font-weight:bold;">*</span> <span style="color:#006666;">1000</span>_000_000<span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#9900CC;">round</span>
  <span style="color:#9966CC; font-weight:bold;">when</span> <span style="color:#ff3333; font-weight:bold;">:MB</span>, <span style="color:#ff3333; font-weight:bold;">:M</span>, <span style="color:#ff3333; font-weight:bold;">:megabyte</span>      <span style="color:#9966CC; font-weight:bold;">then</span> <span style="color:#006600; font-weight:bold;">&#40;</span>value.<span style="color:#9900CC;">to_f</span> <span style="color:#006600; font-weight:bold;">*</span> <span style="color:#006666;">1000</span>_000<span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#9900CC;">round</span>
  <span style="color:#9966CC; font-weight:bold;">when</span> <span style="color:#ff3333; font-weight:bold;">:KB</span>, <span style="color:#ff3333; font-weight:bold;">:K</span>, <span style="color:#ff3333; font-weight:bold;">:kilobyte</span>, <span style="color:#ff3333; font-weight:bold;">:kB</span> <span style="color:#9966CC; font-weight:bold;">then</span> <span style="color:#006600; font-weight:bold;">&#40;</span>value.<span style="color:#9900CC;">to_f</span> <span style="color:#006600; font-weight:bold;">*</span> <span style="color:#006666;">1000</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#9900CC;">round</span>
  <span style="color:#008000; font-style:italic;"># ... even more units here</span>
  <span style="color:#9966CC; font-weight:bold;">else</span> <span style="color:#CC0066; font-weight:bold;">raise</span> <span style="color:#996600;">&quot;Unknown unit: #{unit.inspect}!&quot;</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p>Again this change adds up to a ~1% performance increase if this method is called very often.</p>
<p>These kinds of changes really improved the performance of request-log-analyzer by quite a bit, so upgrade to the latest version to get some of your valuable time back! <img src='http://techblog.floorplanner.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://techblog.floorplanner.com/2009/09/27/performance-tweaking-of-ruby-algorithms/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Counter feedback</title>
		<link>http://techblog.floorplanner.com/2009/03/28/counter-feedback/</link>
		<comments>http://techblog.floorplanner.com/2009/03/28/counter-feedback/#comments</comments>
		<pubDate>Sat, 28 Mar 2009 16:32:14 +0000</pubDate>
		<dc:creator>Willem van Bergen</dc:creator>
				<category><![CDATA[Collaboration]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[counter]]></category>
		<category><![CDATA[flickr]]></category>
		<category><![CDATA[Floorplanner]]></category>
		<category><![CDATA[github]]></category>
		<category><![CDATA[quality improvement]]></category>
		<category><![CDATA[request-log-analyzer]]></category>
		<category><![CDATA[web 2.0]]></category>

		<guid isPermaLink="false">http://techblog.floorplanner.com/?p=561</guid>
		<description><![CDATA[
This week, request-log-analyzer obtained its 100th watcher on GitHub!
Bart and I have worked hard to make r-l-a a useful product for many people in various situations. The fact that more than 100 people are following the project&#8217;s progress and that at this moment, the gem has been download almost 200 times, shows that we are [...]]]></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%2Ftechblog.floorplanner.com%2F2009%2F03%2F28%2Fcounter-feedback%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Ftechblog.floorplanner.com%2F2009%2F03%2F28%2Fcounter-feedback%2F" height="61" width="51" /></a></div><p><a style="float: right" href="http://github.com/wvanbergen/request-log-analyzer/watchers"><img class="size-full wp-image-568 alignright" style="border: 1px solid black;" title="102 request-log-analyzer watchers on Github and counting!" src="http://techblog.floorplanner.com/wp-content/uploads/2009/03/picture-2.png" alt="Request-log-analyzer watchers on Github" width="161" height="26" /></a></p>
<p>This week, <a href="http://github.com/wvanbergen/requets-log-analyzer">request-log-analyzer</a> obtained <a href="http://github.com/wvanbergen/request-log-analyzer/watchers">its 100th watcher on GitHub</a>!</p>
<p>Bart and I have worked hard to make r-l-a a useful product for many people in various situations. The fact that more than 100 people are following the project&#8217;s progress and that at this moment, <a href="http://gems.rubyforge.org/stats.html">the gem has been download almost 200 times</a>, shows that we are somewhat successful in this regard. Numbers like these, in combination with the e-mail messages we have received, motivate us to keep spending time on the project and keep improving it, even if these improvements are not directly useful for our own projects. It has grown beyond <em>scratching our own itch</em>. </p>
<p>On a related note, <a href="http://www.flickr.com/photos/willemvanbergen">my Flickr photostream</a> recently welcomed its 10,000th visitor.</p>
<p style="text-align: center; "><a href="http://www.flickr.com/photos/willemvanbergen"><img class="size-full wp-image-562 aligncenter" style="border: 1px solid black;" title="10,000 visitors on my Flickr photostream!" src="http://techblog.floorplanner.com/wp-content/uploads/2009/03/picture-1.png" alt="10,000 visitors on my Flickr photostream!" width="502" height="84" /></a></p>
<p>What started as a convenient utility to backup and share <a href="http://www.flickr.com/photos/willemvanbergen/collections/72157600336728559/">my holiday photos</a> with my family and friends, now has become somewhat of a showcase of <a href="http://www.flickr.com/photos/willemvanbergen/sets/72157601618255001/">what I</a> <a href="http://www.flickr.com/photos/willemvanbergen/sets/72157594253547759/">am about</a> and <a href="http://www.flickr.com/photos/willemvanbergen/collections/72157607936471141/">what I</a> <a href="http://www.flickr.com/photos/willemvanbergen/sets/72157613466104360/">am up to</a>. I would not consider myself a &#8220;professional&#8221; photographer and I am not an active member of the Flickr community, but still I get feedback on my photographs by visitors, because their visits increase the view counters of my photos.</p>
<p>These counters have really motivated me to make more of an effort when I put photos on Flickr. I started by adding titles, descriptions and tags, so that my photos are easier to find. I also became much more critical of the pictures I upload to Flickr: new uploads have to add something significant to my collection. Analyzing why some pictures got more attention than others made me a better photographer, although there still is a lot of room for improvement. <img src='http://techblog.floorplanner.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />  </p>
<h3>Ignite the lazyweb, kick-start a quality improvement loop</h3>
<p>What interests me in these examples is that simple counters like watchers on GitHub or views on Flickr can be valuable feedback and can motivate people to put in effort. The end result is quality improvement: write better software, make better pictures, etc.. Even an inherently lazy person like me can get motivated to keep putting in effort and to keep improving myself, because of such a simple feedback loop! <img src='http://techblog.floorplanner.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>Additionally, it creates a dependence on the website in question. I look at my Flickr stats page every day, and I am subscribed to my activity feed on GitHub to get notified when new people start watching my projects. I now<em> </em>simply have to publish tools I write on GitHub to boost its quality, immediately and in the long run. And I have to upload pictures to Flickr as it is vital for my photography learning curve.</p>
<p>I guess I finally figured out what Web 2.0 is all about! <img src='http://techblog.floorplanner.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />  Can we use a similar technique on Floorplanner to boost the quality of the designs our visitors make?</p>
]]></content:encoded>
			<wfw:commentRss>http://techblog.floorplanner.com/2009/03/28/counter-feedback/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Request-log-analyzer 1.0</title>
		<link>http://techblog.floorplanner.com/2009/01/12/request-log-analyzer-10/</link>
		<comments>http://techblog.floorplanner.com/2009/01/12/request-log-analyzer-10/#comments</comments>
		<pubDate>Mon, 12 Jan 2009 13:17:38 +0000</pubDate>
		<dc:creator>Willem van Bergen</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA["rails-log-analyzer"]]></category>
		<category><![CDATA[merb]]></category>
		<category><![CDATA[production.log]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[reporting]]></category>
		<category><![CDATA[request-log-analyzer]]></category>
		<category><![CDATA[requests]]></category>
		<category><![CDATA[statistics]]></category>

		<guid isPermaLink="false">http://techblog.floorplanner.com/?p=409</guid>
		<description><![CDATA[After a complete rewrite, Bart and I are proud to present request-log-analyzer version 1.0! Request-log-analyzer is an open-source command-line tool to analyze production log files from your Rails application to produce a performance report.
What&#8217;s new?

More robust log parser. It parses more lines and it now combines all lines that belong to the same request, which greatly [...]]]></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%2Ftechblog.floorplanner.com%2F2009%2F01%2F12%2Frequest-log-analyzer-10%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Ftechblog.floorplanner.com%2F2009%2F01%2F12%2Frequest-log-analyzer-10%2F" height="61" width="51" /></a></div><p>After a complete rewrite, <a title="Bart's Moves on Rails website" href="http://www.movesonrails.com">Bart</a> and I are proud to present <strong>request-log-analyzer</strong> version <strong>1.0!</strong> Request-log-analyzer is an open-source command-line tool to analyze production log files from your Rails application to produce a performance report.</p>
<h3>What&#8217;s new?</h3>
<ul>
<li>More robust log parser. It parses more lines and it now combines all lines that belong to the same request, which greatly improves the amount of information available. </li>
<li>It produces more detailed and more beautiful <a title="Sample report" href="http://wiki.github.com/wvanbergen/request-log-analyzer/sample-output">reports</a>. </li>
<li>A <a href="http://wiki.github.com/wvanbergen/request-log-analyzer/creating-a-request-database">database builder</a> is included, which will create an SQLite 3 database with all parsed request information, so you can roll your own queries.</li>
<li>Request filtering options, so you can exclude irrelevant data. <a title="In-depth analysis example" href="http://wiki.github.com/wvanbergen/request-log-analyzer/in-depth-analysis">An example</a> on how this can be applied in practice can be found in the wiki. </li>
<li>Better, more modularized design under the hood. The parser is now fully log file format-agnostic. Developing extensions and modifications, or adding support for other log file formats should be much easier now. See the <a title="Request-log-analyzer development" href="http://wiki.github.com/wvanbergen/request-log-analyzer/development">development</a>-page for some pointers.</li>
<li>Documentation in the <a href="http://wiki.github.com/wvanbergen/request-log-analyzer">project&#8217;s wiki</a>. Hopefully, this helps people get up to speed with the new version and answers most questions about using the tool. If you still have questions, please contact us so we can keep improving it!</li>
</ul>
<h3>Installation</h3>
<p>Install or upgrade to the new version with the following command:</p>
<pre>$ sudo gem install wvanbergen-request-log-analyzer 
                --source http://gems.github.com</pre>
<p>To get the best results out of request-log-analyzer, it is important to configure logging correctly for your application. Some pointers on how to set things up correctly <a title="Configuring logging correctly" href="http://wiki.github.com/wvanbergen/request-log-analyzer/configure-logging">can be found in the wiki</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://techblog.floorplanner.com/2009/01/12/request-log-analyzer-10/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Rails 2.2 support for request-log-analyzer</title>
		<link>http://techblog.floorplanner.com/2008/12/11/rails-22-support-for-request-log-analyzer/</link>
		<comments>http://techblog.floorplanner.com/2008/12/11/rails-22-support-for-request-log-analyzer/#comments</comments>
		<pubDate>Thu, 11 Dec 2008 12:03:31 +0000</pubDate>
		<dc:creator>Willem van Bergen</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[log files]]></category>
		<category><![CDATA[merb]]></category>
		<category><![CDATA[performance]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[request-log-analyzer]]></category>

		<guid isPermaLink="false">http://techblog.floorplanner.com/?p=316</guid>
		<description><![CDATA[I just released version 0.2.0 of request-log-analyzer, our tool to analyze request log files that are generated by Rails and Merb for performance tweaking. This new version supports the new log format of Rails 2.2, which has changed slightly.
An updated gem should be available any minute now. Run sudo gem update to upgrade the newest [...]]]></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%2Ftechblog.floorplanner.com%2F2008%2F12%2F11%2Frails-22-support-for-request-log-analyzer%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Ftechblog.floorplanner.com%2F2008%2F12%2F11%2Frails-22-support-for-request-log-analyzer%2F" height="61" width="51" /></a></div><p>I just released version 0.2.0 of <a href="http://github.com/wvanbergen/request-log-analyzer">request-log-analyzer</a>, our tool to analyze request log files that are generated by Rails and Merb for performance tweaking. This new version supports the new log format of Rails 2.2, which has changed slightly.</p>
<p>An updated gem should be available any minute now. Run <code>sudo gem update</code> to upgrade the newest version.</p>
]]></content:encoded>
			<wfw:commentRss>http://techblog.floorplanner.com/2008/12/11/rails-22-support-for-request-log-analyzer/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Rails-log-analyzer matures</title>
		<link>http://techblog.floorplanner.com/2008/08/29/rails-log-analyzer-matures/</link>
		<comments>http://techblog.floorplanner.com/2008/08/29/rails-log-analyzer-matures/#comments</comments>
		<pubDate>Fri, 29 Aug 2008 09:49:55 +0000</pubDate>
		<dc:creator>Willem van Bergen</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA["rails-log-analyzer"]]></category>
		<category><![CDATA[Logger]]></category>
		<category><![CDATA[production.log]]></category>
		<category><![CDATA[request-log-analyzer]]></category>
		<category><![CDATA[statistics]]></category>

		<guid isPermaLink="false">http://techblog.floorplanner.com/?p=149</guid>
		<description><![CDATA[Since I announced rails-log-analyzer some weeks ago, quite a lot has happened! Apparently there is some interest in such a tool: on this blog we get a lot of traffic looking for more info, the github project already has 22 watchers and it even has been forked!
In the mean time, Bart and I worked hard [...]]]></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%2Ftechblog.floorplanner.com%2F2008%2F08%2F29%2Frails-log-analyzer-matures%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Ftechblog.floorplanner.com%2F2008%2F08%2F29%2Frails-log-analyzer-matures%2F" height="61" width="51" /></a></div><p>Since I <a href="http://techblog.floorplanner.com/2008/08/15/rails-log-analyzer/">announced</a> rails-log-analyzer some weeks ago, quite a lot has happened! Apparently there is some interest in such a tool: on this blog we get a lot of traffic looking for more info, the <a href="http://github.com/wvanbergen/request-log-analyzer/">github project</a> already has <a href="http://github.com/wvanbergen/request-log-analyzer/watchers">22 watchers</a> and it even has been <a href="http://github.com/mattpolito/rails-log-analyzer/tree">forked</a>!</p>
<p>In the mean time, Bart and I worked hard to add new functionality and refactored the internal design. As a result, I have released <strong>request-log-analyzer 0.1.0</strong> today!</p>
<h3>Changes: </h3>
<ul>
<li>The project is renamed to <em>request-log-analyzer</em>, because we plan to support log files from other frameworks as well; Merb is planned to be supported in the near future.</li>
<li>The tool is distributed as a gem, making it much easier to install and update.</li>
<li>More reports, colorized output, parsing progress bars, command line arguments, etc&#8230;</li>
<li>Added a tool to create a SQLite database with all the parsed info from the log file, so you can do your own analysis.</li>
</ul>
<h3>Installation:</h3>
<pre>gem sources -a http://gems.github.com
sudo gem install wvanbergen-request-log-analyzer</pre>
<h3>Usage:</h3>
<pre>request-log-analyzer  [LOG FILES*]
request-log-analyzer -c 20 -z log/production.log</pre>
<p>Please let me know what you think! If you have any problems using the tool, do not hesitate to contact me!</p>
]]></content:encoded>
			<wfw:commentRss>http://techblog.floorplanner.com/2008/08/29/rails-log-analyzer-matures/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>Rails log analyzer</title>
		<link>http://techblog.floorplanner.com/2008/08/15/rails-log-analyzer/</link>
		<comments>http://techblog.floorplanner.com/2008/08/15/rails-log-analyzer/#comments</comments>
		<pubDate>Fri, 15 Aug 2008 05:31:40 +0000</pubDate>
		<dc:creator>Willem van Bergen</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA["rails-log-analyzer"]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[request-log-analyzer]]></category>
		<category><![CDATA[statistics]]></category>

		<guid isPermaLink="false">http://techblog.floorplanner.com/?p=138</guid>
		<description><![CDATA[My friend Bart from movesonrails.com just blogged about Rails log analyzer, a command line tool to get performance statistics for your Rails application by parsing its log file.
What started as an exercise for me to write a command line ruby program, has been extended and improved by Bart to be actually useful! We decided to [...]]]></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%2Ftechblog.floorplanner.com%2F2008%2F08%2F15%2Frails-log-analyzer%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Ftechblog.floorplanner.com%2F2008%2F08%2F15%2Frails-log-analyzer%2F" height="61" width="51" /></a></div><p>My friend Bart from <a href="http://movesonrails.com">movesonrails.com</a> just <a href="http://movesonrails.com/articles/2008/08/14/rails-log-analyzer">blogged about Rails log analyzer</a>, a command line tool to get performance statistics for your Rails application by parsing its log file.</p>
<p>What started as an exercise for me to write a command line ruby program, has been extended and improved by Bart to be actually useful! We decided to release it under an MIT license. You can found the source on <a href="http://github.com/wvanbergen/request-log-analyzer/tree/master">github</a>. The <a href="http://github.com/wvanbergen/request-log-analyzer/wikis">project&#8217;s wiki</a> contains usage information and an example of the output it will produce. </p>
]]></content:encoded>
			<wfw:commentRss>http://techblog.floorplanner.com/2008/08/15/rails-log-analyzer/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>
