<?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>Gorges Blog &#187; performance</title>
	<atom:link href="http://blog.GORGES.us/tag/performance/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.GORGES.us</link>
	<description>Web Sites that Grow Your Business - our blog</description>
	<lastBuildDate>Thu, 02 Sep 2010 12:12:37 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>When to Optimize Code for Performance</title>
		<link>http://blog.GORGES.us/2009/05/when-to-optimize/</link>
		<comments>http://blog.GORGES.us/2009/05/when-to-optimize/#comments</comments>
		<pubDate>Mon, 04 May 2009 13:00:09 +0000</pubDate>
		<dc:creator>Matt Clark</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[optimization]]></category>
		<category><![CDATA[performance]]></category>

		<guid isPermaLink="false">http://blog.GORGES.us/?p=71</guid>
		<description><![CDATA[Of course writing bad or inefficient code is not a good way to develop code.  But spending time optimizing code before you know there is a problem can be a waste of time.  I value legible and readable code over unnecessarily-optimized code anyday.]]></description>
			<content:encoded><![CDATA[<p><strong>Question</strong>:  When should a web developer optimize?</p>
<p><strong>Answer</strong>:  When you have to improve the performance.</p>
<p>Of course writing bad or inefficient code is not a good way to develop code.  But spending time optimizing code before you know there is a problem can be a waste of time.  I value legible and readable code over unnecessarily-optimized code anyday.</p>
<p>If a web page or certain feature is too slow, then diagnosing exactly where to optimize is appropriate.  Here are some things to consider and test:</p>
<dl>
<dt>Is the bottleneck in the code or within a database call?</dt>
<dd>Perhaps the database needs to be indexed or normalized.</dd>
<dt>How many SQL calls are being performed?</dt>
<dd>Caching the database calls may solve this issue.</dd>
<dt>Is a database the best solution for storing all your information?</dt>
<dd>LDAP or memcache are two other options that may work best depending on what you are trying to do.</dd>
<dt>Are your files and images just too big?</dt>
<dd>Be sure the images are appropriately compressed, and that server-side compression for text files (HTML, CSS, JavaScript, XML) is activated.</dd>
<dt>Could any of the heavy logic code be pre-computed?</dt>
<dd>I recall one project (<a href="http://straightlineps.com">Straight Line Performance Solutions</a>) where I pre-computed a big table of possible values from a complicated statistical function, and just looked up an approximate number quickly instead of spending 5-10 seconds computing the exact value.</dd>
<dt>Are you using a bloated CMS (content management system)?</dt>
<dd>If you are and the web pages are static, then a page-caching system will work wonders.</dd>
<dt>Is the server limited by bandwidth, RAM, or CPU?</dt>
<dd>Monitor server performance indicators to see if  there is too much disk thrashing.  Hardware is relatively cheap nowadays, and may be a better solution than spending days unsuccessfully tweaking code.</dd>
<dt>Does the page <em>feel</em> like it loads fast enough?</dt>
<dd>Perception is everything to a web user.  Some non-essential web page items could be changed to load a few seconds after the visible part of the web page is loaded and refreshed.  For example, there&#8217;s no reason to preload all images in a Javascript-based slide show.</dd>
<dt>Is there just too much traffic to your site?</dt>
<dd>Wow &#8211; what a great problem to have!  Maybe it&#8217;s time to scale your web application to multiple servers or host your application in the cloud.  There are sometimes session-management issues when using multiple web servers, but some real smart folks have figured most of this out for the major languages and popular frameworks.</dd>
</dl>
<p>There are only some ideas of what to look for &#8211; and I&#8217;m sure I missed a bunch of simple ones.  As you can see, I recommend spending time diagnosing the real problem before jumping in and optimizing code right away.</p>
<p>I&#8217;d rather have a correct program than a fast incorrect one.  Optimizing code when needed is better than having to debug faulty code.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.GORGES.us/2009/05/when-to-optimize/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
