示例#1
0
 public static function filenameFromIteration(Iteration $iteration)
 {
     $name = sprintf('%s::%s.P%s.cachegrind', $iteration->getSubject()->getBenchmarkMetadata()->getClass(), $iteration->getSubject()->getName(), $iteration->getParameters()->getIndex());
     $name = str_replace('\\', '_', $name);
     $name = str_replace('/', '_', $name);
     return $name;
 }
示例#2
0
 /**
  * {@inheritdoc}
  */
 public function execute(Iteration $iteration, Config $config)
 {
     $subject = $iteration->getSubject();
     $tokens = array('class' => $subject->getBenchmarkMetadata()->getClass(), 'file' => $subject->getBenchmarkMetadata()->getPath(), 'subject' => $subject->getName(), 'revolutions' => $iteration->getRevolutions(), 'beforeMethods' => var_export($subject->getBeforeMethods(), true), 'afterMethods' => var_export($subject->getAfterMethods(), true), 'parameters' => var_export($iteration->getParameters()->getArrayCopy(), true));
     $payload = $this->launcher->payload(__DIR__ . '/template/microtime.template', $tokens);
     return $this->launch($payload, $iteration, $config);
 }
示例#3
0
 public function iterationStart(Iteration $iteration)
 {
     if ($this->isCi) {
         return;
     }
     $state = $iteration->getIndex() % 4;
     $states = array(0 => '|', 1 => '/', 2 => '-', 3 => '\\');
     $this->output->write(sprintf("\r%s%s", $this->buffer, $states[$state]));
 }
示例#4
0
 protected function formatIterationTime(Iteration $iteration)
 {
     $subject = $iteration->getSubject();
     $timeUnit = $subject->getOutputTimeUnit();
     $outputMode = $subject->getOutputMode();
     $time = 0;
     if ($iteration->hasResult()) {
         $time = $iteration->getResult()->getTime() / $iteration->getRevolutions();
     }
     return number_format($this->timeUnit->toDestUnit($time, $this->timeUnit->resolveDestUnit($timeUnit), $this->timeUnit->resolveMode($outputMode)), $this->timeUnit->getPrecision());
 }
示例#5
0
 /**
  * {@inheritdoc}
  */
 public function execute(Iteration $iteration, array $options = array())
 {
     $subject = $iteration->getSubject();
     $tokens = array('class' => $subject->getBenchmarkMetadata()->getClass(), 'file' => $subject->getBenchmarkMetadata()->getPath(), 'subject' => $subject->getName(), 'revolutions' => $iteration->getRevolutions(), 'beforeMethods' => var_export($subject->getBeforeMethods(), true), 'afterMethods' => var_export($subject->getAfterMethods(), true), 'parameters' => var_export($iteration->getParameters()->getArrayCopy(), true));
     $payload = $this->launcher->payload(__DIR__ . '/template/microtime.template', $tokens);
     $payload->setPhpConfig(array('max_execution_time' => 0));
     $result = $payload->launch();
     if (isset($result['buffer']) && $result['buffer']) {
         throw new \RuntimeException(sprintf('Benchmark made some noise: %s', $result['buffer']));
     }
     return new IterationResult($result['time'], $result['memory']);
 }
 /**
  * @description persist and find nodes using raw PHPCR
  * @iterations 4
  * @paramProvider provideNodeTotals
  * @paramProvider provideLocales
  * @beforeMethod init
  */
 public function benchCreatePersistPhpcr(Iteration $iteration)
 {
     $session = $this->getSession();
     $baseNode = $session->getNode(self::BASE_PATH);
     for ($i = 0; $i < $iteration->getParameter('nb_nodes'); ++$i) {
         $node = $baseNode->addNode('node-' . $i);
         foreach ($iteration->getParameter('locales') as $locale) {
             $node->addMixin('mix:test');
             $node->setProperty('lsys:' . $locale . '-created', new \DateTime());
             $node->setProperty('lsys:' . $locale . '-changed', new \DateTime());
         }
     }
     $session->save();
 }
示例#7
0
 /**
  * {@inheritdoc}
  */
 public function execute(Iteration $iteration, Config $config)
 {
     $memory = 100;
     $collectionHash = spl_object_hash($iteration->getCollection());
     if (!$config['times']) {
         return new IterationResult(0, $memory);
     }
     if (isset($this->collectionTimes[$collectionHash])) {
         $time = $this->collectionTimes[$collectionHash];
     } else {
         $index = count($this->collectionTimes) % count($config['times']);
         $time = $config['times'][$index];
         $this->collectionTimes[$collectionHash] = $time;
     }
     if ($config['spread']) {
         $index = $iteration->getIndex() % count($config['spread']);
         $spreadDiff = $config['spread'][$index];
         $time = $time + $spreadDiff;
     }
     return new IterationResult($time, $memory);
 }
示例#8
0
 /**
  * {@inheritdoc}
  */
 public function iterationStart(Iteration $iteration)
 {
     $this->drawIterations($iteration->getCollection(), $this->rejects, 'error', $iteration->getIndex());
     $this->output->write(PHP_EOL);
     $this->output->write("");
     // clear the line
     $this->output->write(PHP_EOL);
     $this->output->write(sprintf('<info>subject</info> %s<info> with </info>%s<info> iteration(s) of </info>%s<info> rev(s),</info>', sprintf('%s', $iteration->getCollection()->getSubject()->getName()), $iteration->getCollection()->count(), $iteration->getRevolutions()));
     $this->output->write(PHP_EOL);
     $this->output->write(sprintf('<info>parameters</info> %s', json_encode($iteration->getCollection()->getParameterSet()->getArrayCopy(), true)));
     $this->output->write("[" . ($this->depth + 3) . 'A');
     // put the cursor back to the line with the measurements
     $this->output->write("");
     // put the cursor back at col 0
 }
示例#9
0
 /**
  * {@inheritdoc}
  */
 public function iterationStart(Iteration $iteration)
 {
     $this->output->write(sprintf("    %-30s%sI%s P%s ", $iteration->getSubject()->getName(), $this->rejectionCount ? 'R' . $this->rejectionCount . ' ' : '', $iteration->getIndex(), $iteration->getParameters()->getIndex()));
 }
示例#10
0
 private function getYPos(Iteration $iteration)
 {
     return floor($iteration->getIndex() / self::NUMBER_COLS);
 }
示例#11
0
 /**
  * {@inheritdoc}
  */
 public function iterationStart(Iteration $iteration)
 {
     $this->output->write(PHP_EOL);
     $this->output->write(PHP_EOL);
     $this->output->write(sprintf('<info>it</info>%3d/%-3d<info> (rej </info>%s<info>)</info>', $iteration->getIndex(), $iteration->getCollection()->count(), $iteration->getCollection()->getRejectCount()));
     $this->output->write("");
     $this->output->write("");
 }