, , :
function function_exists_cached($function_name)
{
static $cache = array();
if(isset($cache[$function_name]))
return $cache[$function_name];
return ($cache[$function_name] = \function_exists($function_name));
}
$funcs = \array_shift(\get_defined_functions());
$a = new \core\utiles\loadTime;
$times = $tot = 0;
$a->start();
for($index = 0; $index<count($funcs); $index++)
{
foreach($funcs as $func)
{
$times++;
if(\function_exists($func)) ;
}
}
$s = $a->stop();
$tot+=$s;
echo "<b>None Cached : </b><b><span style='color:green'>#$times</span></b> function check took : $s seconds<br />";
$b = new \core\utiles\loadTime;
$times = 0;
$b->start();
static $func_check = array();
for($index = 0; $index<count($funcs); $index++)
{
foreach($funcs as $func)
{
$times++;
if(!isset($func_check[$func]))
{
if(\function_exists($func)) ;
$func_check[$func] = 1;
}
else $func_check[$func];
}
}
$s = $b->stop();
$tot+=$s;
echo "<b>Fly Cached : </b><b><span style='color:green'>#$times</span></b> function check took : $s seconds<br />";
$c = new \core\utiles\loadTime;
$times = 0;
$c->start();
for($index = 0; $index<count($funcs); $index++)
{
foreach($funcs as $func)
{
$times++;
if(\function_exists_cached($func)) ;
}
}
$s = $c->stop();
$tot+=$s;
echo "<b>Function Cached : </b><b><span style='color:green'>#$times</span></b> function check took : $s seconds<br />";
echo "Total time : $tot seconds";
:
: # 2365444 : 0.69758
Fly Cached: # 2365444 : 0,5307
: # 2365444 : 1.02575
: 2.25403
, ,
function_exists_cached($function_name) Fly Cached, ?