optimization

Improve PHP file loading

I think you have already known that require/include is faster than require_once/include_one. But sometime, we also need the functionality of require_once but do not suffer from the performance tradeoff. So here is a better way to re-invent PHP implement.

function requireOnce($file)
{
static $dict=array();

if (!isset($dict[$file]))
{
require $file;
$dict[$file] = true;
}
}

Category:

The best way to access PHP global variable

I have been playing with PHP minor optimization for a while, but this is the first time I go for it seriously. My question for today is what's the best way to work with PHP global variables and how to achieve best performance for it. Rumours say that global keyword is slow, so this is a good time to check it out. And I also want to check if the number of variables affects the performance of the method.

Setup

Category:

Design Fast Website

Subscribe to RSS - optimization