Commit fe133dea authored by Arnaud Bey's avatar Arnaud Bey
Browse files

add some infos in grid generation command

parent 9dc7be09
......@@ -21,6 +21,8 @@ class GenerateGridCommand extends ContainerAwareCommand
protected function execute(InputInterface $input, OutputInterface $output)
{
$output->writeln('<info>################### GO! ####################################################</info>');
$em = $this->getContainer()->get('doctrine')->getEntityManager('default');
$gridManager = $this->getContainer()->get('mw_manager.grid');
$number = $input->getArgument('number');
......@@ -30,6 +32,8 @@ class GenerateGridCommand extends ContainerAwareCommand
$totalFormCountAll = 0;
$keptGrid = 0;
$allGrid = 0;
$best = 0;
$worst = 1000;
while ($keptGrid < $number) {
$language = $em->getRepository('LexiconBundle:Language')->findOneByValue($languageName);
......@@ -39,7 +43,8 @@ class GenerateGridCommand extends ContainerAwareCommand
$executionTime = round($timeEnd - $timeStart, 2);
$formCount = $grid->getFoundableForms()? count($grid->getFoundableForms()) : 0;
$totalFormCountAll += $formCount;
$best = ($formCount > $best) ? $formCount : $best;
$worst = ($formCount < $worst) ? $formCount : $worst;
if ($threshold && $formCount < $threshold) {
$output->writeln('<comment>A grid has been generated but does not contains enough forms ('.$formCount.'). (generated in '.$executionTime.' sec.)</comment>');
$gridId = $grid->getId();
......@@ -55,18 +60,24 @@ class GenerateGridCommand extends ContainerAwareCommand
$em->flush();
} else {
$keptGrid++;
$output->writeln('<info>('.$keptGrid.') A grid has been generated and contains ('.$formCount.') forms (generated in '.$executionTime.' sec.)</info>');
$output->writeln('<info>('.$keptGrid.') A grid has been generated and contains '.$formCount.' forms (generated in '.$executionTime.' sec.)</info>');
$totalFormCount += $formCount;
}
$em->clear();
$allGrid++;
$averageAll = round($totalFormCountAll / $allGrid);
$output->writeln('Average form count for all '.$allGrid.' grids : <error>'.$averageAll.'</error>');
$output->writeln('');
}
$average = round($totalFormCount / $keptGrid);
$output->writeln('<info>################### DONE ! ############################################</info>');
$output->writeln('Average form count: for '. $keptGrid .' kept grids : <error>'.$average.'</error>');
$averageAll = round($totalFormCountAll / $allGrid);
$output->writeln('<info>Done ! (average form count: '.$average.')</info>');
$output->writeln('<info>Done ! (average form count for all grids: '.$averageAll.')</info>');
$output->writeln('Average form count for all '. $allGrid .' grids : <error>'.$averageAll.'</error>');
$output->writeln('Best grid : <error>'.$best.'</error>');
$output->writeln('Worst grid : <error>'.$worst.'</error>');
$output->writeln('<info>#######################################################################</info>');
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment