<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Elliot Loves Perl &#187; Benchmark</title>
	<atom:link href="http://elliotlovesperl.com/tag/benchmark/feed/" rel="self" type="application/rss+xml" />
	<link>http://elliotlovesperl.com</link>
	<description>A boy and his language</description>
	<lastBuildDate>Wed, 17 Feb 2010 12:43:40 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='elliotlovesperl.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://1.gravatar.com/blavatar/7899c71f1e2dd5c5fa1b1ec047ffdf34?s=96&#038;d=http://s2.wp.com/i/buttonw-com.png</url>
		<title>Elliot Loves Perl &#187; Benchmark</title>
		<link>http://elliotlovesperl.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://elliotlovesperl.com/osd.xml" title="Elliot Loves Perl" />
	<atom:link rel='hub' href='http://elliotlovesperl.com/?pushpress=hub'/>
		<item>
		<title>Using NYTProf to understand why not to do something.</title>
		<link>http://elliotlovesperl.com/2009/06/06/using-nytprof-to-understand-why-not-to-do-something/</link>
		<comments>http://elliotlovesperl.com/2009/06/06/using-nytprof-to-understand-why-not-to-do-something/#comments</comments>
		<pubDate>Sat, 06 Jun 2009 17:32:19 +0000</pubDate>
		<dc:creator>elliotlovesperl</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Benchmark]]></category>
		<category><![CDATA[DateTime]]></category>
		<category><![CDATA[Devel::NYTProf]]></category>
		<category><![CDATA[modules]]></category>
		<category><![CDATA[performance]]></category>
		<category><![CDATA[profiling]]></category>

		<guid isPermaLink="false">http://elliotlovesperl.wordpress.com/?p=102</guid>
		<description><![CDATA[Mr. Bunce is asking for examples of how NYTProf told you what to fix with poorly performing code. Instead, I&#8217;m going to give an example of how NYTProf told me why I shouldn&#8217;t fix something a particular way. I&#8217;ve got an app that needs to analyze a bunch of logs. Having used NYTProf in the [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=elliotlovesperl.com&amp;blog=7775865&amp;post=102&amp;subd=elliotlovesperl&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Mr. Bunce is <a href="http://blog.timbunce.org/2009/06/05/has-nytprof-helped-you-tell-me-how/">asking for examples</a> of how <a href="http://search.cpan.org/dist/Devel-NYTProf/">NYTProf</a> told you what to fix with poorly performing code.</p>
<p>Instead, I&#8217;m going to give an example of how NYTProf told me why I shouldn&#8217;t fix something a particular way.</p>
<p>I&#8217;ve got an app that needs to analyze a bunch of logs.  Having used NYTProf in the past to identify that creation of <a href="http://search.cpan.org/dist/DateTime/">DateTime</a> objects is my biggest issue, I was thinking of ways to improve the situation.  One thing I thought of is being able to create a DateTime based upon an epoch time instead of individual date components (year, month, etc.), with the idea that the cost of deriving the epoch time from the date components was what was expensive (I can affect the format of some of the logs, and thus could get the epoch time emitted).  So, I quickly threw together a little <a href="http://search.cpan.org/perldoc?Benchmark">Benchmark</a> program that compared the costs of constructing DateTimes from each type of data.  I was shocked to discover that creating objects based upon epoch times was over 20% more expensive than creating them out of date components.</p>
<p>What was going on?  NYTProf provided me with the answer.  I created two simple programs that created 100,000 DateTime objects, one for each kind of constructor arguments.  I profiled both of them and compared the NYTProf output for them.  This led me to looking at the <code>from_epoch()</code> code in the NYTProf generated HTML, and finding that DateTime passes the epoch time to <code>gmtime</code> to get the date components and then calls the regular constructor with those.  The extra cost isn&#8217;t really in the <code>gmtime</code> calls, but a good part of it is in the use of <a href="http://search.cpan.org/dist/Params-Validate/">Params::Validate</a> in all of the public methods to check arguments and the epoch time path takes the code path through an additional public method.</p>
<p>Benchmark told me that I shouldn&#8217;t make a change and NYTProf allowed me to understand why that that result was correct and there wasn&#8217;t something wrong with my Benchmark use.</p>
<br /> Tagged: Benchmark, DateTime, Devel::NYTProf, modules, performance, profiling <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/elliotlovesperl.wordpress.com/102/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/elliotlovesperl.wordpress.com/102/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/elliotlovesperl.wordpress.com/102/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/elliotlovesperl.wordpress.com/102/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/elliotlovesperl.wordpress.com/102/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/elliotlovesperl.wordpress.com/102/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/elliotlovesperl.wordpress.com/102/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/elliotlovesperl.wordpress.com/102/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/elliotlovesperl.wordpress.com/102/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/elliotlovesperl.wordpress.com/102/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/elliotlovesperl.wordpress.com/102/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/elliotlovesperl.wordpress.com/102/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/elliotlovesperl.wordpress.com/102/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/elliotlovesperl.wordpress.com/102/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=elliotlovesperl.com&amp;blog=7775865&amp;post=102&amp;subd=elliotlovesperl&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://elliotlovesperl.com/2009/06/06/using-nytprof-to-understand-why-not-to-do-something/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e2e2e6430cc24b91f3c25f25fba6d9e6?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">elliotlovesperl</media:title>
		</media:content>
	</item>
	</channel>
</rss>