<?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>The Life of RubenV (Ruben Vermeersch) &#187; performance</title>
	<atom:link href="http://weblog.savanne.be/tags/performance/feed" rel="self" type="application/rss+xml" />
	<link>http://weblog.savanne.be</link>
	<description></description>
	<lastBuildDate>Mon, 30 Jan 2012 14:14:23 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Using Federicos timeline tool with Mono</title>
		<link>http://weblog.savanne.be/156-using-federicos-timeline-tool-with-mono</link>
		<comments>http://weblog.savanne.be/156-using-federicos-timeline-tool-with-mono#comments</comments>
		<pubDate>Sat, 17 Jan 2009 07:44:07 +0000</pubDate>
		<dc:creator>Ruben</dc:creator>
				<category><![CDATA[gnome]]></category>
		<category><![CDATA[mono]]></category>
		<category><![CDATA[performance]]></category>

		<guid isPermaLink="false">http://weblog.savanne.be/156-using-federicos-timeline-tool-with-mono</guid>
		<description><![CDATA[<p>While figuring out why Tomboy takes quite a lot of time to start (<a href="http://bugzilla.gnome.org/show_bug.cgi?id=567989">BGO #567989</a>, hint: it&#8217;s not the lack of SQLite), I was reminded of Lord Kelvins old saying: &#8220;To measure is to know&#8221;.</p>
<p>Thinking how to quantify this, it occured to me that the GNOME community has the perfect tool for figuring out slowness: <a href="http://www.gnome.org/~federico/hacks/index.html#performance-scripts">Federicos awesome timeline tool</a>. All I had to do is figure out how to use this with Mono, which is very easy, as you will see below.</p>
<div align="center"><a href="/tomboy-timeline.png"><img src="/tomboy-timeline-small.png" alt="Tomboy startup" border="0" /></a><br />
<em>Tomboy startup (click for a full size graph)</em></div>
<p>Federico uses a <a href="http://www.gnome.org/~federico/news-2006-03.html#timeline-tools">nice trick using syscalls</a>, which are logged using strace. Fortunately, this is very easy to reproduce with C#.</p>
<ol>
<li>First we need to generate them, add something like this to your program:<br />
<small><code><br />
public class TraceLogger {<br />
&nbsp; &nbsp; public static void trace (string group, string format, params object[] args)<br />
&nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; string message = String.Format (format, args);<br />
&nbsp; &nbsp; &nbsp; &nbsp; string str = String.Format ("MARK: {0}: {1}", group, message);<br />
&nbsp; &nbsp; &nbsp; &nbsp; Mono.Unix.Native.Syscall.access(str, Mono.Unix.Native.AccessModes.F_OK);<br />
&nbsp; &nbsp; }<br />
}<br />
</code></small></li>
<li>Liberally sprinkle tracing statements in your code, like this: <code>TraceLogger.trace("Main", "Starting main loop");</code></li>
<li>Modify your startup script so that the line containing &#8220;<code>exec mono ...</code>&#8221; now reads &#8220;<code>exec strace -ttt -f -o /tmp/timeline.strace mono ....</code>&#8220;.</li>
<li>Use Federicos script to plot it: <code>python plot-timeline.py -o graph.png /tmp/timeline.strace</code>.</li>
</ol>
<p>That&#8217;s all there is to it. The attentive reader will notice that I used the tracing format a bit differently, rather than printing the program name, I use a group parameter. This makes the graph easier to interpret: if you add too many tracing statements, it might be hard to see where the big gaps are. Hijacking the color coding avoids this interpretation difficulty.</p>
<p>Now hurry up and make your Mono apps even faster!</p>
]]></description>
			<content:encoded><![CDATA[<p>While figuring out why Tomboy takes quite a lot of time to start (<a href="http://bugzilla.gnome.org/show_bug.cgi?id=567989">BGO #567989</a>, hint: it&#8217;s not the lack of SQLite), I was reminded of Lord Kelvins old saying: &#8220;To measure is to know&#8221;.</p>
<p>Thinking how to quantify this, it occured to me that the GNOME community has the perfect tool for figuring out slowness: <a href="http://www.gnome.org/~federico/hacks/index.html#performance-scripts">Federicos awesome timeline tool</a>. All I had to do is figure out how to use this with Mono, which is very easy, as you will see below.</p>
<div align="center"><a href="/tomboy-timeline.png"><img src="/tomboy-timeline-small.png" alt="Tomboy startup" border="0" /></a><br />
<em>Tomboy startup (click for a full size graph)</em></div>
<p>Federico uses a <a href="http://www.gnome.org/~federico/news-2006-03.html#timeline-tools">nice trick using syscalls</a>, which are logged using strace. Fortunately, this is very easy to reproduce with C#.</p>
<ol>
<li>First we need to generate them, add something like this to your program:<br />
<small><code><br />
public class TraceLogger {<br />
&nbsp; &nbsp; public static void trace (string group, string format, params object[] args)<br />
&nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; string message = String.Format (format, args);<br />
&nbsp; &nbsp; &nbsp; &nbsp; string str = String.Format ("MARK: {0}: {1}", group, message);<br />
&nbsp; &nbsp; &nbsp; &nbsp; Mono.Unix.Native.Syscall.access(str, Mono.Unix.Native.AccessModes.F_OK);<br />
&nbsp; &nbsp; }<br />
}<br />
</code></small></li>
<li>Liberally sprinkle tracing statements in your code, like this: <code>TraceLogger.trace("Main", "Starting main loop");</code></li>
<li>Modify your startup script so that the line containing &#8220;<code>exec mono ...</code>&#8221; now reads &#8220;<code>exec strace -ttt -f -o /tmp/timeline.strace mono ....</code>&#8220;.</li>
<li>Use Federicos script to plot it: <code>python plot-timeline.py -o graph.png /tmp/timeline.strace</code>.</li>
</ol>
<p>That&#8217;s all there is to it. The attentive reader will notice that I used the tracing format a bit differently, rather than printing the program name, I use a group parameter. This makes the graph easier to interpret: if you add too many tracing statements, it might be hard to see where the big gaps are. Hijacking the color coding avoids this interpretation difficulty.</p>
<p>Now hurry up and make your Mono apps even faster!</p>
]]></content:encoded>
			<wfw:commentRss>http://weblog.savanne.be/156-using-federicos-timeline-tool-with-mono/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

