Permalink
Browse files

Use Median...

  • Loading branch information...
ShaneMcC committed Dec 2, 2018
1 parent 9901ecb commit 51677c2b2736c9317d410a062b3e1f31b685f385
Showing with 14 additions and 1 deletion.
  1. +14 −1 www/index.php
@@ -22,7 +22,20 @@ function getTime($times, $method) {
$parsedTimes = array_chunk($parsedTimes, count($parsedTimes) - 5)[0];
return array_sum($parsedTimes) / count($parsedTimes);
case 'MEDIAN':
$count = count($parsedTimes);
$middle = floor(($count - 1) / 2);
if ($count % 2) {
return $parsedTimes[$middle];
} else {
$low = $parsedTimes[$middle];
$high = $parsedTimes[$middle + 1];
return (($low + $high) / 2);
}
case 'AVG':
case 'MEAN':
return array_sum($parsedTimes) / count($parsedTimes);
case 'MIN':
@@ -52,7 +65,7 @@ function formatTime($time) {
return sprintf('%dm%d.%03ds', $m, $s, $ms);
}
$method = isset($_REQUEST['method']) ? $_REQUEST['method'] : 'SPECIAL';
$method = isset($_REQUEST['method']) ? $_REQUEST['method'] : 'MEDIAN';
$hasResults = false;
if (file_exists($resultsFile)) {

0 comments on commit 51677c2

Please sign in to comment.