Location: PHPKode > scripts > RogePHP > RoguePHP-0.9.4/RoguePHP-0.9.4/tests/define_performance.php
<?php


$num = 10000;

$s1 = microtime(true);
for ($i=0; $i<$num; $i++)
{
define('DEF'.$i, 'A VALUE'.$i);
}
$s2 = microtime(true);
echo "$num defines takes: " . (round(($s2-$s1), 5)) . " sec\n";


$s1 = microtime(true);
for ($i=0; $i<$num; $i++)
{
$_GLOBALS['DEF'.$i]='A VALUE'.$i;
}
$s2 = microtime(true);
echo "$num variable assign takes: " . (round(($s2-$s1), 5)) . " sec\n";


$s1 = microtime(true);
for ($i=0; $i<$num; $i++)
{
$x = DEF1;
}
$s2 = microtime(true);
echo "$num fetch takes: " . (round(($s2-$s1), 5)) . " sec\n";


$s1 = microtime(true);
for ($i=0; $i<$num; $i++)
{
$x=$_GLOBALS['DEF1'];
}
$s2 = microtime(true);
echo "$num variable fetch takes: " . (round(($s2-$s1), 5)) . " sec\n";

?>
Return current item: RogePHP