- microtime: documentation ( source)
- round: documentation ( source)
- error_reporting: documentation ( source)
<?php
error_reporting(E_ALL);
$iterations = 1000000;
$start = microtime(true);
for ($i=0; $i<$iterations; $i++) {
$page = @$_GET['page'] ?: 'home';
}
$suppressedTime = round(microtime(true) - $start, 8);
$start = microtime(true);
for ($i=0; $i<$iterations; $i++) {
$page = isset($_GET['page']) ? $_GET['page'] : 'home';
}
$issetTime = round(microtime(true) - $start, 8);
echo "results for {$iterations} iterations:\n\n";
echo "suppressed time: {$suppressedTime}\n";
echo "isset time: {$issetTime}\n";
echo "speed difference: " . round($suppressedTime / 100 * $issetTime, 2) . "%";