- microtime: documentation ( source)
<?php
$time1 = microtime(true);
for ($i = 0; $i < 500000; $i ++) {
$a = 1/3 * 1/3;
}
$time2 = microtime(true);
for ($i = 0; $i < 500000; $i ++) {
$a = bcmul(bcdiv(1, 3, 42), bcdiv(1, 3, 42), 42);
}
$time3 = microtime(true);
echo "floating point: " . ($time2 - $time1) . "us" . PHP_EOL . "bcmath: " . ($time3 - $time2) . "us";