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); }
private function getSuiteDocument() { $suite = new SuiteDocument(); $suite->loadXml(<<<EOT <?xml version="1.0"?> <phpbench version="0.x"> <benchmark class="Foobar"> <subject name="mySubject"> <variant> <parameter name="foo" value="bar" /> <parameter name="array" type="collection"> <parameter name="0" value="one" /> <parameter name="1" value="two" /> </parameter> <parameter name="assoc_array" type="collection"> <parameter name="one" value="two" /> <parameter name="three" value="four" /> </parameter> <iteration time="100" memory="100" revs="1" /> <iteration time="75" memory="100" revs="1" /> </variant> </subject> </benchmark> </phpbench> EOT ); return $suite; }
public function execute(InputInterface $input, OutputInterface $output) { $reports = $input->getOption('report'); $reportNames = $this->reportManager->processCliReports($reports); $file = $input->getArgument('file'); if (!$reportNames) { throw new \InvalidArgumentException('You must specify or configure at least one report, e.g.: --report=simple'); } if (!file_exists($file)) { throw new \InvalidArgumentException(sprintf('Could not find suite result file "%s"', $file)); } $suiteResult = new SuiteDocument(); $suiteResult->loadXml(file_get_contents($file)); $this->reportManager->generateReports($output, $suiteResult, $reportNames); }
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); }
private function getMultipleSuiteDocument() { $suite = new SuiteDocument(); $suite->loadXml(<<<EOT <?xml version="1.0"?> <phpbench version="0.x"> <suite context="foobar"> <benchmark class="Foobar"> <subject name="mySubject"> <variant output-time-unit="microseconds"> <iteration time="100" memory="100" revs="1" deviation="1" rejection-count="0"/> <iteration time="75" memory="100" revs="1" deviation="2" rejection-count="0"/> </variant> </subject> </benchmark> </suite> <suite context="barfoo"> <benchmark class="Foobar"> <subject name="mySubject"> <variant output-time-unit="microseconds"> <iteration time="100" memory="100" revs="1" deviation="1" rejection-count="0"/> <iteration time="75" memory="100" revs="1" deviation="2" rejection-count="0"/> </variant> </subject> </benchmark> </suite> </phpbench> EOT ); return $suite; }