<?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>PHP Software Developing &#187; running time</title>
	<atom:link href="http://www.phpdeveloping.co.za/tag/running-time/feed" rel="self" type="application/rss+xml" />
	<link>http://www.phpdeveloping.co.za</link>
	<description>for the love of PHP Development</description>
	<lastBuildDate>Tue, 29 Sep 2009 15:38:14 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>How long does your script run?</title>
		<link>http://www.phpdeveloping.co.za/performance/how-long-does-your-script-run.html</link>
		<comments>http://www.phpdeveloping.co.za/performance/how-long-does-your-script-run.html#comments</comments>
		<pubDate>Wed, 12 Aug 2009 19:51:48 +0000</pubDate>
		<dc:creator>chris</dc:creator>
				<category><![CDATA[Performance]]></category>
		<category><![CDATA[load speed]]></category>
		<category><![CDATA[running time]]></category>

		<guid isPermaLink="false">http://www.phpdeveloping.co.za/?p=127</guid>
		<description><![CDATA[A while back I launched WebSpeedTest.co.za which is just a little script to check how long it takes to load your website.  It doesn&#8217;t take into account loading of all objects on the website, just the HTML.
Some of the code can be used in your PHP script to see how long it takes to [...]]]></description>
			<content:encoded><![CDATA[<p>A while back I launched <a href="http://www.webspeedtest.co.za/">WebSpeedTest.co.za</a> which is just a little script to check how long it takes to load your website.  It doesn&#8217;t take into account loading of all objects on the website, just the HTML.</p>
<p>Some of the code can be used in your PHP script to see how long it takes to load.</p>
<p>First what you do is add this at the very top of your script.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$time</span> <span style="color: #339933;">=</span> <span style="color: #990000;">microtime</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$time</span> <span style="color: #339933;">=</span> <span style="color: #990000;">explode</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">' '</span><span style="color: #339933;">,</span> <span style="color: #000088;">$time</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$time</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$time</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">+</span> <span style="color: #000088;">$time</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$start</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$time</span><span style="color: #339933;">;</span></pre></div></div>

<p>That will have recorded your start time in the variable $start.</p>
<p>Now, at the very end of your script add this in:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$time</span> <span style="color: #339933;">=</span> <span style="color: #990000;">microtime</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$time</span> <span style="color: #339933;">=</span> <span style="color: #990000;">explode</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">' '</span><span style="color: #339933;">,</span> <span style="color: #000088;">$time</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$time</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$time</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">+</span> <span style="color: #000088;">$time</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$finish</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$time</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$total_time</span> <span style="color: #339933;">=</span> <span style="color: #990000;">round</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$finish</span> <span style="color: #339933;">-</span> <span style="color: #000088;">$start</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">4</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>$total_time now contains the amount of seconds it took to run your script.  This can be useful for debugging to check where you might have bottlenecks.  </p>
]]></content:encoded>
			<wfw:commentRss>http://www.phpdeveloping.co.za/performance/how-long-does-your-script-run.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
