- microtime: documentation ( source)
<?php
function foo() {
$foo = 'bar';
}
$bar = function() {
$foo = 'bar';
};
$tries = 1E5;
$start = microtime(true);
for ($i = 0; $i < $tries; $i++) {
foo();
}
echo (microtime(true) - $start);
$start = microtime(true);
for ($i = 0; $i < $tries; $i++) {
$bar();
}
echo (microtime(true) - $start);