Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Simple PHP benchmarking script
$benchmark_time = microtime(1);
$benchmark_string = '';
function benchmark( $string = ''){
global $benchmark_time, $benchmark_string;
$return = sprintf('%f', microtime(1) - $benchmark_time) . 's ' . $benchmark_string;
$benchmark_time = microtime(1);
$benchmark_string = $string;
return $return;
echo benchmark('START').PHP_EOL;
echo benchmark('Sleep one second').PHP_EOL;
echo benchmark('Sleep two seconds').PHP_EOL;
echo benchmark('END').PHP_EOL;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment