<?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>SmileyLover Blog &#187; php counter processing</title>
	<atom:link href="http://blog.smileylover.com/tag/php-counter-processing/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.smileylover.com</link>
	<description>Sharing Knowledge and Resources</description>
	<lastBuildDate>Sun, 04 Apr 2010 18:32:35 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=abc</generator>
		<item>
		<title>Calculation Your PHP Processing Time Using Simple Counter</title>
		<link>http://blog.smileylover.com/calculation-your-php-processing-time-using-simple-counter/</link>
		<comments>http://blog.smileylover.com/calculation-your-php-processing-time-using-simple-counter/#comments</comments>
		<pubDate>Mon, 27 Oct 2008 19:50:59 +0000</pubDate>
		<dc:creator>Admin</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[php counter processing]]></category>

		<guid isPermaLink="false">http://blog.smileylover.com/?p=109</guid>
		<description><![CDATA[It&#8217;s a good idea for PHP progammer to know how fast their application process. With this info they can decide what best coding to achieve high perfomance. We&#8217;ll using microtime() function that&#8217;s already exist in PHP. Microtime will returns the current timestamp with microseconds. The basic idea is when first PHP running the process, counting [...]


Related posts:<ol><li><a href='http://blog.smileylover.com/making-border-image-with-php-and-gd-library/' rel='bookmark' title='Permanent Link: Making Border Image with PHP and GD Library'>Making Border Image with PHP and GD Library</a></li>
<li><a href='http://blog.smileylover.com/simple-ajax-captcha/' rel='bookmark' title='Permanent Link: Simple AJAX Captcha'>Simple AJAX Captcha</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;">It&#8217;s a good idea for PHP progammer to know how fast their application process.  With this info they can decide what best coding to achieve high perfomance.  We&#8217;ll using <strong>microtime()</strong> function that&#8217;s already exist in PHP.  Microtime will returns the current timestamp with microseconds.</p>
<p style="text-align: justify;">The basic idea is when first PHP running the process, counting function will work and note as begin time and when process is finished counting function call again and note as end time.  From this two variable we can get all processing time by decrease end time with begin time.  The result will return in microseconds.</p>
<p style="text-align: justify;"><span id="more-109"></span></p>
<p style="text-align: justify;">Now it&#8217;s full code.  Place this code in first line after open tag PHP if possible ( be carefull with any session function).</p>
<p style="text-align: justify;">

<div class="wp_codebox_msgheader wp_codebox_hide"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p109code3'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p1093"><td class="code" id="p109code3"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$time</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/explode"><span style="color: #990000;">explode</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">' '</span><span style="color: #339933;">,</span> <a href="http://www.php.net/microtime"><span style="color: #990000;">microtime</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</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: #666666; font-style: italic;">// return array</span>
<span style="color: #000088;">$begintime</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$time</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//define begin time</span></pre></td></tr></table></div>

<p style="text-align: justify;">And place this code before closing tag PHP.</p>
<p style="text-align: justify;">

<div class="wp_codebox_msgheader wp_codebox_hide"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p109code4'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p1094"><td class="code" id="p109code4"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$time</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/explode"><span style="color: #990000;">explode</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot; &quot;</span><span style="color: #339933;">,</span> <a href="http://www.php.net/microtime"><span style="color: #990000;">microtime</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</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;">$endtime</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$time</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//define end time</span>
<span style="color: #000088;">$totaltime</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$endtime</span> <span style="color: #339933;">-</span> <span style="color: #000088;">$begintime</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//decrease to get total time</span>
<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$totaltime</span><span style="color: #339933;">.</span><span style="color: #0000ff;">' seconds'</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//echo it to appear in browser</span></pre></td></tr></table></div>

<p style="text-align: justify;">Now anytime your PHP running it will return how long the process took <img src='http://blog.smileylover.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<script type="text/javascript" class="owbutton" src="http://onlywire.com/btn/button_3793" title="Calculation Your PHP Processing Time Using Simple Counter" url="http://blog.smileylover.com/calculation-your-php-processing-time-using-simple-counter/"></script>

<p>Related posts:<ol><li><a href='http://blog.smileylover.com/making-border-image-with-php-and-gd-library/' rel='bookmark' title='Permanent Link: Making Border Image with PHP and GD Library'>Making Border Image with PHP and GD Library</a></li>
<li><a href='http://blog.smileylover.com/simple-ajax-captcha/' rel='bookmark' title='Permanent Link: Simple AJAX Captcha'>Simple AJAX Captcha</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.smileylover.com/calculation-your-php-processing-time-using-simple-counter/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>
