コード例 #1
0
ファイル: ReportCommand.php プロジェクト: stof/phpbench
 public function execute(InputInterface $input, OutputInterface $output)
 {
     $reports = $input->getOption('report');
     $reportNames = $this->reportManager->processCliReports($reports);
     $files = $input->getOption('file');
     $outputs = $input->getOption('output');
     $outputNames = $this->reportManager->processCliOutputs($outputs);
     if (!$files) {
         throw new \InvalidArgumentException('You must specify at least one result --file (generated by the run command\'s `--dump-file=` option)');
     }
     if (!$reportNames) {
         throw new \InvalidArgumentException('You must specify or configure at least one report, e.g.: --report=default');
     }
     $aggregateDom = new SuiteDocument();
     $aggregateEl = $aggregateDom->createRoot('phpbench');
     foreach ($files as $file) {
         if (!file_exists($file)) {
             throw new \InvalidArgumentException(sprintf('Could not find suite result file "%s" (cwd: %s)', $file, getcwd()));
         }
         $suiteResult = new SuiteDocument();
         $suiteResult->loadXml(file_get_contents($file));
         foreach ($suiteResult->xpath()->query('//suite') as $suiteEl) {
             $suiteEl = $aggregateDom->importNode($suiteEl, true);
             if (!$suiteEl->getAttribute('name')) {
                 $suiteEl->setAttribute('name', basename($file));
             }
             $aggregateEl->appendChild($suiteEl);
         }
     }
     $this->reportManager->renderReports($output, $aggregateDom, $reportNames, $outputNames);
 }
コード例 #2
0
ファイル: ReportCommand.php プロジェクト: Remo/phpbench
 public function execute(InputInterface $input, OutputInterface $output)
 {
     $files = $input->getOption('file');
     if (!$files) {
         throw new \InvalidArgumentException('You must specify at least one result --file (generated by the run command\'s `--dump-file=` option)');
     }
     if (!$input->getOption('report')) {
         throw new \InvalidArgumentException('You must specify or configure at least one report, e.g.: --report=default');
     }
     $this->timeUnitHandler->timeUnitFromInput($input);
     $aggregateDom = new SuiteDocument();
     $aggregateDom->createRoot('phpbench');
     foreach ($files as $file) {
         if (!file_exists($file)) {
             throw new \InvalidArgumentException(sprintf('Could not find suite result file "%s" (cwd: %s)', $file, getcwd()));
         }
         $suiteResult = new SuiteDocument();
         $suiteResult->loadXml(file_get_contents($file));
         $aggregateDom->appendSuiteDocument($suiteResult, basename($file));
     }
     $this->reportHandler->reportsFromInput($input, $output, $aggregateDom);
 }