Exemplo n.º 1
0
 /**
  * {@inheritdoc}
  */
 public function fetch($runId)
 {
     if (!$this->has($runId)) {
         throw new \InvalidArgumentException(sprintf('Cannot find run with UUID "%s"', $runId));
     }
     $path = $this->getPath($runId);
     $dom = new Document();
     $dom->load($path);
     $collection = $this->xmlDecoder->decode($dom);
     return $collection;
 }
Exemplo n.º 2
0
 public function createResult($benchmark = null, $extraCmd = '')
 {
     $benchmark = $benchmark ?: 'benchmarks/set4';
     $process = $this->phpbench('run ' . $benchmark . ' --executor=debug --dump-file=' . $this->fname . ' ' . $extraCmd);
     if ($process->getExitCode() !== 0) {
         throw new \Exception('Could not generate test data:' . $process->getErrorOutput() . $process->getOutput());
     }
     $document = new Document();
     $document->load($this->fname);
     return $document;
 }
Exemplo n.º 3
0
 /**
  * Return a SuiteCollection from a number of PHPBench xml files.
  *
  * @param string[] $files
  *
  * @return SuiteCollection
  */
 public function decodeFiles(array $files)
 {
     // combine into one document.
     //
     $suiteDocument = new Document('phpbench');
     $rootEl = $suiteDocument->createRoot('phpbench');
     foreach ($files as $file) {
         $fileDom = new Document();
         $fileDom->load($file);
         foreach ($fileDom->query('./suite') as $suiteEl) {
             $importedEl = $suiteDocument->importNode($suiteEl, true);
             $rootEl->appendChild($importedEl);
         }
     }
     return $this->decode($suiteDocument);
 }
Exemplo n.º 4
0
 /**
  * Hydrate and return the history entry for the given path.
  *
  * The summary *should* used pre-calculated values from the XML
  * therefore reducing the normal overhead, however this code
  * is still quite expensive as we are creating the entire object
  * graph for each suite run.
  *
  * @param string $path
  *
  * @return HistoryEntry
  */
 private function getHistoryEntry($path)
 {
     $dom = new Document();
     $dom->load($path);
     $collection = $this->xmlDecoder->decode($dom);
     $suites = $collection->getSuites();
     $suite = reset($suites);
     $envInformations = $suite->getEnvInformations();
     $vcsBranch = null;
     if (isset($envInformations['vcs']['branch'])) {
         $vcsBranch = $envInformations['vcs']['branch'];
     }
     $summary = $suite->getSummary();
     $entry = new HistoryEntry($suite->getUuid(), $suite->getDate(), $suite->getContextName(), $vcsBranch, $summary->getNbSubjects(), $summary->getNbIterations(), $summary->getNbRevolutions(), $summary->getMinTime(), $summary->getMaxTime(), $summary->getMeanTime(), $summary->getMeanRelStDev(), $summary->getTotalTime());
     return $entry;
 }
Exemplo n.º 5
0
 /**
  * It should expand items from an expression when a source document is given.
  */
 public function testColumnNamesItems()
 {
     $dom = new Document();
     $dom->load(__DIR__ . '/files/articles.xml');
     $definition = $this->loader->load(array('rows' => array(array('cells' => array(array('name' => '{{ cell.item }}', 'literal' => 'bar', 'with_items' => array('selector' => '//article', 'value' => 'string(./@name)')))))), $dom);
     $this->assertEquals(array('one', 'two', 'three'), $definition->getColumnNames());
 }
Exemplo n.º 6
0
 /**
  * {@inheritdoc}
  */
 public function restore(OutputInterface $output)
 {
     $driver = $this->storageRegistry->getService();
     $iterator = new \DirectoryIterator($this->archivePath);
     $files = $this->filterFiles($iterator);
     $totalCount = count($files);
     $files = $this->filterExisting($driver, $files);
     $count = count($files);
     $output->writeln(sprintf('Restoring %s of %s suites.', $count, $totalCount));
     foreach ($files as $index => $file) {
         $this->writeProgress($output, $index, $count, '.');
         $document = new Document();
         $document->load($file->getPathname());
         $collection = $this->xmlDecoder->decode($document);
         $driver->store($collection);
     }
     $output->write(PHP_EOL);
 }