<?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>Aditya Kothadiya&#039;s Blog &#187; speed</title>
	<atom:link href="http://adityakothadiya.com/tag/speed/feed/" rel="self" type="application/rss+xml" />
	<link>http://adityakothadiya.com</link>
	<description>Entrepreneurship, programming, design, productivity, books, philosophy and more.</description>
	<lastBuildDate>Sun, 16 May 2010 16:20:16 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>The PHP Benchmark</title>
		<link>http://adityakothadiya.com/2009/04/the-php-benchmark/</link>
		<comments>http://adityakothadiya.com/2009/04/the-php-benchmark/#comments</comments>
		<pubDate>Sat, 18 Apr 2009 18:00:01 +0000</pubDate>
		<dc:creator>Aditya</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[performance]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[speed]]></category>

		<guid isPermaLink="false">http://adityakothadiya.com/?p=425</guid>
		<description><![CDATA[I just stumbled upon a website called PHP Benchmark. It&#8217;s a great resource to learn PHP tips for improving performance and speed. These are not advanced tips, but rather very simple tips that we generally don&#8217;t pay attention to in our day-to-day programming.
Here is one example -
Is it worth the effort to calculate the length [...]]]></description>
			<content:encoded><![CDATA[<p>I just stumbled upon a website called <a href="http://www.phpbench.com/" target="_blank">PHP Benchmark</a>. It&#8217;s a great resource to learn PHP tips for improving performance and speed. These are not advanced tips, but rather very simple tips that we generally don&#8217;t pay attention to in our day-to-day programming.</p>
<p>Here is one example -</p>
<p><strong>Is it worth the effort to calculate the length of the loop in advance?</strong></p>
<p>E.g. Should we use</p>
<pre class="brush: php;">

for ($i = 0; $i &lt; $size; $i++)
</pre>
<p>instead of</p>
<pre class="brush: php;">

for ($i = 0; $i &lt; sizeof($arr); $i++)
</pre>
<p>The performance result for a loop with 1000 keys with 1 byte values is as below -</p>
<blockquote><p><strong>With pre calc &#8211; count():</strong> Total time: 229 µs<br />
<strong>Without pre calc &#8211; count():</strong> Total time: 99702 µs<br />
<strong>With pre calc &#8211; sizeof(): </strong>Total time: 235 µs<br />
<strong>Without pre calc &#8211; sizeof():</strong> Total time: 99610 µs</p></blockquote>
<p>So it&#8217;s very clear that calculating the length of array in advance is way faster than calculating it in the loop.</p>
<p>I hope you&#8217;ll find other tips from PHP Benchmark website very useful too.</p>
]]></content:encoded>
			<wfw:commentRss>http://adityakothadiya.com/2009/04/the-php-benchmark/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
