- microtime: documentation ( source)
<?php
$limit = 100000;
$t0 = microtime(true);
for ($i = 0; $i < $limit; ++$i) {
$j = $i % 10 === 0;
}
echo microtime(true) - $t0 . PHP_EOL;
$t0 = microtime(true);
for ($i = 0; $i < $limit; ++$i) {
$j = $i & 1;
}
echo microtime(true) - $t0 . PHP_EOL;
$t0 = microtime(true);
for ($i = 0; $i < $limit; ++$i) {
$j = (bool) $i & 10;
}
echo microtime(true) - $t0 . PHP_EOL;