Permalink
Browse files

Only run changes.

  • Loading branch information...
ShaneMcC committed Dec 2, 2018
1 parent 5275318 commit 80d5717d51525d131e52d04c806d83814b07d8b9
Showing with 34 additions and 11 deletions.
  1. +31 −9 bench.php
  2. +1 −0 config.php
  3. +2 −2 www/index.php
@@ -4,6 +4,12 @@
require_once(__DIR__ . '/config.php');
$results = [];
if (file_exists($resultsFile)) {
$data = json_decode(file_get_contents($resultsFile), true);
if (isset($data['results'])) {
$results = $data['results'];
}
}
foreach ($participants as $participant) {
$person = $participant->getName();
@@ -27,35 +33,51 @@
echo 'Preparing.', "\n";
$participant->prepare();
$results[$person] = [];
$results[$person]['name'] = $person;
$results[$person]['repo'] = $participant->getRepo();
$results[$person]['days'] = [];
if (!isset($results[$person])) {
$results[$person] = [];
$results[$person]['name'] = $person;
$results[$person]['repo'] = $participant->getRepo();
$results[$person]['days'] = [];
}
// Run day.
for ($day = 1; $day <= 25; $day++) {
echo 'Day ', $day, ': ';
$results[$person]['days'][$day] = [];
if (isset($results[$person]['days'][$day]['version'])) {
if ($results[$person]['days'][$day]['version'] == $participant->getVersion($day)) {
echo 'No changes.', "\n";
continue;
}
}
$results[$person]['days'][$day] = ['times' => []];
// Run 10 times.
for ($i = 0; $i < 10; $i++) {
$long = false;
for ($i = 0; $i < ($long ? 4 : 10); $i++) {
$start = time();
$result = $participant->run($day);
$end = time();
// Long-Running days, run less times.
if ($end - $start > 30) { $long = true; }
if ($result === NULL) { echo '!'; break; } else { echo $i; }
// Get the `real` time output.
$time = $result[count($result) - 3];
$time = trim(preg_replace('#^real#', '', $time));
$results[$person]['days'][$day][] = $time;
$results[$person]['days'][$day]['times'][] = $time;
}
echo "\n";
if (empty($results[$person]['days'][$day])) {
if (empty($results[$person]['days'][$day]['times'])) {
unset($results[$person]['days'][$day]);
break;
} else {
sort($results[$person]['days'][$day]);
sort($results[$person]['days'][$day]['times']);
$results[$person]['days'][$day]['version'] = $participant->getVersion($day);
}
}
}
@@ -10,6 +10,7 @@ abstract class Participant {
abstract function getRepo();
abstract function prepare();
abstract function run($day);
abstract function getVersion($day);
}
// Local configuration.
@@ -27,8 +27,8 @@
foreach ($particpants as $particpant) {
echo '<td>';
if (isset($data['results'][$particpant]['days'][$day])) {
echo $data['results'][$particpant]['days'][$day][0];
if (isset($data['results'][$particpant]['days'][$day]['times'])) {
echo $data['results'][$particpant]['days'][$day]['times'][0];
} else {
echo '&nbsp;';
}

0 comments on commit 80d5717

Please sign in to comment.