-
-
Save alexpott/202a520d3bec69a8d1d6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function quantile($values, $p) { | |
sort($values); | |
$H = (count($values) - 1) * $p + 1; | |
$h = floor($H); | |
$v = $values[$h - 1]; | |
$e = $H - $h; | |
return $e ? $v + $e * ($values[$h] - $v) : $v; | |
} | |
function sumarize($values) { | |
$output = array(); | |
$output['min'] = number_format(min($values), 4); | |
$output['max'] = number_format(max($values), 4); | |
$output['mean'] = number_format(array_sum($values) / count($values), 4); | |
$output['median'] = number_format(quantile($values, 0.5), 4); | |
$output['95th'] = number_format(quantile($values, 0.95), 4); | |
return $output; | |
} | |
$file_list = shell_exec('find core| grep -v vendor | grep \.yml$'); | |
$files = array_filter(explode("\n", $file_list)); | |
$md5_times = array(); | |
$sha_times = array(); | |
foreach ($files as $file) { | |
$string = file_get_contents($file); | |
$start = microtime(TRUE); | |
md5($string); | |
$md5_times[] = (microtime(TRUE) - $start) * 1000; | |
$start = microtime(TRUE); | |
hash('sha512', $string); | |
$sha_times[] = (microtime(TRUE) - $start) * 1000; | |
} | |
print_r(sumarize($md5_times)); | |
print_r(sumarize($sha_times)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment