コード例 #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
ファイル: SuiteDocument.php プロジェクト: Remo/phpbench
 /**
  * Append the suites container in another document to this document.
  *
  * @param SuiteDocument $suiteDocument
  * @param string $defaultName
  */
 public function appendSuiteDocument(SuiteDocument $suiteDocument, $defaultName = null)
 {
     $aggregateEl = $this->evaluate('/phpbench')->item(0);
     if (null === $aggregateEl) {
         throw new \InvalidArgumentException('Suite document must have root element "phpbench" before appending other suites');
     }
     foreach ($suiteDocument->xpath()->query('//suite') as $suiteEl) {
         $suiteEl = $this->importNode($suiteEl, true);
         if (!$suiteEl->getAttribute('name')) {
             $suiteEl->setAttribute('name', $defaultName);
         }
         $aggregateEl->appendChild($suiteEl);
     }
 }