- microtime: documentation ( source)
- number_format: documentation ( source)
<?php
$xy = microtime(true);
$n = 10000;
while (--$n)
{
$a = 'hello, world!';
}
// multiplication and formatting do not count as they go after the subtraction
echo ("\nExecution took: " . number_format((microtime(true) - $xy) * 1000000, 0, '.', '') . " microsecond(s).\n");