Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Simple PHP benchmarking script
<?php
$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;
sleep(1);
echo benchmark('Sleep two seconds').PHP_EOL;
sleep(2);
echo benchmark('END').PHP_EOL;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment