<?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>Technocrat &#187; php</title>
	<atom:link href="http://www.techn0crat.com/category/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.techn0crat.com</link>
	<description>Technocrat's Random Thoughts</description>
	<lastBuildDate>Wed, 03 Feb 2010 00:39:52 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>phpInputValidator</title>
		<link>http://www.techn0crat.com/2010/02/phpinputvalidator-2/</link>
		<comments>http://www.techn0crat.com/2010/02/phpinputvalidator-2/#comments</comments>
		<pubDate>Wed, 03 Feb 2010 00:39:52 +0000</pubDate>
		<dc:creator>Technocrat</dc:creator>
				<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.techn0crat.com/?p=226</guid>
		<description><![CDATA[phpInputValidator has a new site and a new release:
http://www.phpInputValidator.org
]]></description>
			<content:encoded><![CDATA[<p>phpInputValidator has a new site and a new release:</p>
<p><a href="http://www.phpInputValidator.org">http://www.phpInputValidator.org</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.techn0crat.com/2010/02/phpinputvalidator-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Loading a class test</title>
		<link>http://www.techn0crat.com/2009/08/loading-a-class-test/</link>
		<comments>http://www.techn0crat.com/2009/08/loading-a-class-test/#comments</comments>
		<pubDate>Sun, 23 Aug 2009 03:41:48 +0000</pubDate>
		<dc:creator>Technocrat</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[class]]></category>
		<category><![CDATA[include]]></category>
		<category><![CDATA[loading]]></category>
		<category><![CDATA[micro time]]></category>
		<category><![CDATA[require]]></category>
		<category><![CDATA[spl_autoload_register]]></category>
		<category><![CDATA[testing]]></category>

		<guid isPermaLink="false">http://www.techn0crat.com/?p=202</guid>
		<description><![CDATA[I wanted to find out what is the fastest way to load a class in PHP.  So I took the different ways to do it and tested them using microtime.  What I found was a little surprising.
Here is the setup:
Each file will use:
$time_start = microtime(true);
To start the timer and:
$time_end = microtime(true);
$time = $time_end - $time_start;
var_dump($time);
To [...]]]></description>
			<content:encoded><![CDATA[<p>I wanted to find out what is the fastest way to load a class in PHP.  So I took the different ways to do it and tested them using microtime.  What I found was a little surprising.</p>
<p>Here is the setup:</p>
<p>Each file will use:</p>
<pre class="brush:php">$time_start = microtime(true);</pre>
<p>To start the timer and:</p>
<pre class="brush:php">$time_end = microtime(true);
$time = $time_end - $time_start;
var_dump($time);</pre>
<p>To stop the timer and give me the time it took to run the code.</p>
<p>For this test my class is VERY simple:</p>
<pre class="brush:php">class Test {
  function __construct() {
    echo 'test';
  }

  public function make() {
    echo 'test2';
  }
}</pre>
<p>To run my code I used:</p>
<pre class="brush:php">$test = new Test();
$test->make();</pre>
<p>All this will be in an index.php file.</p>
<p>My first test was to use a direct path to a file that contained the class (I found that include vs require was not a noticeable difference in time.  However require_once or include_once was slower).  So the code I used was:</p>
<pre class="brush:php">include dirname(__FILE__).'/class.test.inc.php';</pre>
<p>This came back with an average of: 0.0001089</p>
<p>My second test was to use the spl_autoload_register function.  So for this test I used:</p>
<pre class="brush:php">spl_autoload_register('loader');

function loader($class_name) {
	switch ($class_name) {
		case 'Test':
			include dirname(__FILE__).'/class.test.inc.php';
		break;
	}
}</pre>
<p>This came back with an average of: 0.0001218<br />
Which is a bit slower than the first test.  Really this isn&#8217;t a major difference in speed but it is slower.</p>
<p>My next test was to add the path to the include path using:</p>
<pre class="brush:php">set_include_path(dirname(__FILE__).PATH_SEPARATOR.get_include_path());
include 'class.test.inc.php';</pre>
<p>This came back with an average of: 0.0001239<br />
So this is slower than the previous but again not a major difference.</p>
<p>My final test was to put the class in the file.  This really had a surprising result.<br />
This came back with an average of: 1.788139.  WOW!  That&#8217;s a big difference!  This would be a noticeable difference to a user.</p>
<p>Very interesting.  So it would seem that if you really want to have the quickest setup for your program it would seem that the direct path is by far the best.  Putting a class into a file that uses it is not.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.techn0crat.com/2009/08/loading-a-class-test/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
