- microtime: documentation ( source)
- test2: documentation ( source)
<?php
function foo($in = false) {}
function test($in) {
$start = microtime(true);
for ($i = 0; $i < 10000; $i++) {
foo(!!$in);
}
echo ((microtime(true) - $start) / 1000)."\n";
}
function test2($in) {
$start = microtime(true);
for ($i = 0; $i < 10000; $i++) {
foo((boolean)$in);
}
echo ((microtime(true) - $start) / 1000)."\n";
}
test($tmp);
test2($tmp);
echo "\n";
$tmp = false;
test($tmp);
test2($tmp);
echo "\n";
$tmp = '0';
test($tmp);
test2($tmp);