public static function run(Route $route, AdapterInterface $console, $container)
{
$error = 0;
$oldPath = $route->getMatchedParam("old", "/tmp/bench/current.json");
$newPath = $route->getMatchedParam("new", "./athletic_output.json");
$old = json_decode(file_get_contents($oldPath), true);
$new = json_decode(file_get_contents($newPath), true);
$comparator = $container->get(ComparatorService::class);
foreach ($new as $group => $values) {
if (!array_key_exists($group, $old)) {
continue;
}
$newAvg = (double) $values['trigger']['avg'];
$oldAvg = (double) $old[$group]['trigger']['avg'];
$perct = $comparator->perctDecrease($newAvg, $oldAvg);
if ($perct >= 5) {
$error = 1;
$console->writeLine("{$group} +{$perct}%", ColorInterface::RED);
} elseif ($perct < -10) {
$console->writeLine("{$group} {$perct}%", ColorInterface::GREEN);
} else {
$console->writeLine("{$group} {$perct}%", ColorInterface::NORMAL);
}
}
return $error;
}