Permalink
Browse files

Normalise input.

  • Loading branch information...
ShaneMcC committed Dec 3, 2018
1 parent 33e0bb8 commit b364baaaa53daadecc5c1c32c4d34320e44050a7
Showing with 28 additions and 1 deletion.
  1. +24 −1 bench.php
  2. +4 −0 config.php
@@ -60,6 +60,21 @@ function saveData() {
pcntl_signal(SIGTERM, $shutdownFunc);
pcntl_async_signals(true);
function getInput($day) {
global $participants, $participantsDir;
$source = $participants[0];
$cwd = getcwd();
chdir($participantsDir . '/' . $source->getName());
$input = $source->getInput($day);
chdir($cwd);
return $input;
}
foreach ($participants as $participant) {
$person = $participant->getName();
echo "\n", $person , ': ', "\n";
@@ -71,6 +86,7 @@ function saveData() {
if (file_exists($dir)) {
echo 'Updating Repo.', "\n";
chdir($dir);
exec('git reset --hard origin 2>&1');
exec('git pull 2>&1');
} else {
echo 'Cloning Repo.', "\n";
@@ -110,7 +126,14 @@ function saveData() {
$results[$person]['days'][$day] = ['times' => []];
// Run 10 times.
if ($normaliseInput) {
$input = getInput($day);
if ($input !== FALSE) {
$participant->setInput($day, $input);
}
}
// Run 20 times.
$long = false;
$hasRun = false;
for ($i = 0; $i < ($long ? $longRepeatCount : $repeatCount); $i++) {
@@ -7,6 +7,8 @@
$longTimeout = 30;
$longRepeatCount = 10;
$normaliseInput = true;
$participants = [];
abstract class Participant {
@@ -15,6 +17,8 @@ abstract class Participant {
abstract function prepare();
abstract function run($day);
abstract function getVersion($day);
abstract function getInput($day);
abstract function setInput($day, $input);
function extractTime($output) {
$time = $output[count($output) - 3];

0 comments on commit b364baa

Please sign in to comment.