Skip to content

Instantly share code, notes, and snippets.

@vojkny
Created August 18, 2011 22:40
Show Gist options
  • Save vojkny/1155460 to your computer and use it in GitHub Desktop.
Save vojkny/1155460 to your computer and use it in GitHub Desktop.
<?php
function fun() {return (3.75*0.12345*12345*9.999);};
function test() {
$start = microtime(true);
$s = 'php';
for ($i = 0; $i < call_user_func('fun'); $i += (0.5 + 0.5)) {
$s = preg_replace('#[02468]#', 'X', sha1(md5($s)));
}
return microtime(true) - $start;
}
$total = 0;
$it = 10;
for ($i = 0; $i < $it; $i++) {
$total += test();
sleep(1);
}
printf('Average time of %d iterations: %f seconds.', $it, $total/$it);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment