Example #1
0
 private function processBenchmark(Benchmark $benchmark, \DOMElement $suiteEl)
 {
     $benchmarkEl = $suiteEl->appendElement('benchmark');
     $benchmarkEl->setAttribute('class', $benchmark->getClass());
     foreach ($benchmark->getSubjects() as $subject) {
         $this->processSubject($subject, $benchmarkEl);
     }
 }
Example #2
0
 /**
  * {@inheritdoc}
  */
 public function benchmarkStart(Benchmark $benchmark)
 {
     static $first = true;
     if (false === $first) {
         $this->output->write(PHP_EOL);
     }
     $first = false;
     $this->output->writeln(sprintf('<comment>%s</comment>', $benchmark->getClass()));
     $this->output->write(PHP_EOL);
 }
Example #3
0
 public function benchmarkStart(Benchmark $benchmark)
 {
     static $first = true;
     if ($this->showBench) {
         // do not output a line break on the first run
         if (false === $first) {
             $this->output->writeln('');
         }
         $first = false;
         $this->output->writeln($benchmark->getClass());
     }
 }
Example #4
0
 private function getSubject(\ArrayObject $context, Benchmark $benchmark, $row)
 {
     $key = $row['run.uuid'] . $row['subject.benchmark'] . $row['subject.name'];
     if (isset($context[self::SUBJECTS][$key])) {
         return $context[self::SUBJECTS][$key];
     }
     $subject = $benchmark->createSubject($row['subject.name']);
     $subject->setSleep($row['variant.sleep']);
     $subject->setOutputTimeUnit($row['variant.output_time_unit']);
     $subject->setOutputTimePrecision($row['variant.output_time_precision']);
     $subject->setOutputMode($row['variant.output_mode']);
     $context[self::SUBJECTS][$key] = $subject;
     $groups = $this->repository->getGroups($row['subject.id']);
     $subject->setGroups($groups);
     return $subject;
 }
Example #5
0
 /**
  * {@inheritdoc}
  */
 public function benchmarkStart(Benchmark $benchmark)
 {
     static $first = true;
     if (false === $first) {
         $this->output->write(PHP_EOL);
     }
     $first = false;
     $this->output->write(sprintf('<comment>%s</comment>', $benchmark->getClass()));
     $subjectNames = [];
     foreach ($benchmark->getSubjects() as $index => $subject) {
         $subjectNames[] = sprintf('#%s %s', $index, $subject->getName());
     }
     $this->output->write(sprintf(' (%s)', implode(', ', $subjectNames)));
     $this->output->write(PHP_EOL);
     $this->output->write(PHP_EOL);
 }
Example #6
0
 private function processBenchmark(Benchmark $benchmark, \DOMElement $benchmarkEl, array $resultClasses)
 {
     foreach ($benchmarkEl->query('./subject') as $subjectEl) {
         $subject = $benchmark->createSubject($subjectEl->getAttribute('name'));
         $this->processSubject($subject, $subjectEl, $resultClasses);
     }
 }
Example #7
0
 /**
  * {@inheritdoc}
  */
 public function benchmarkStart(Benchmark $benchmark)
 {
     $this->output->writeln(sprintf('<comment>%s</comment>', $benchmark->getClass()));
     $this->output->write(PHP_EOL);
 }
Example #8
0
 /**
  * @param BenchmarkMetadata $benchmark
  * @param string $name
  */
 public function __construct(Benchmark $benchmark, $name)
 {
     $this->benchmark = $benchmark;
     $this->name = $name;
     $this->index = count($benchmark->getSubjects());
 }
Example #9
0
 private function runBenchmark(ExecutorInterface $executor, RunnerContext $context, Benchmark $benchmark, BenchmarkMetadata $benchmarkMetadata)
 {
     if ($benchmarkMetadata->getBeforeClassMethods()) {
         $executor->executeMethods($benchmarkMetadata, $benchmarkMetadata->getBeforeClassMethods());
     }
     // the keys are subject names, convert them to numerical indexes.
     $subjectMetadatas = array_filter($benchmarkMetadata->getSubjects(), function ($subjectMetadata) {
         if ($subjectMetadata->getSkip()) {
             return false;
         }
         return true;
     });
     $subjectMetadatas = array_values($subjectMetadatas);
     foreach ($subjectMetadatas as $subjectMetadata) {
         // override parameters
         $subjectMetadata->setIterations($context->getIterations($subjectMetadata->getIterations()));
         $subjectMetadata->setRevs($context->getRevolutions($subjectMetadata->getRevs()));
         $subjectMetadata->setWarmup($context->getWarmup($subjectMetadata->getWarmUp()));
         $subjectMetadata->setSleep($context->getSleep($subjectMetadata->getSleep()));
         $subjectMetadata->setRetryThreshold($context->getRetryThreshold($this->retryThreshold));
         $benchmark->createSubjectFromMetadata($subjectMetadata);
     }
     $this->logger->benchmarkStart($benchmark);
     foreach ($benchmark->getSubjects() as $index => $subject) {
         $subjectMetadata = $subjectMetadatas[$index];
         $this->logger->subjectStart($subject);
         $this->runSubject($executor, $context, $subject, $subjectMetadata);
         $this->logger->subjectEnd($subject);
     }
     $this->logger->benchmarkEnd($benchmark);
     if ($benchmarkMetadata->getAfterClassMethods()) {
         $executor->executeMethods($benchmarkMetadata, $benchmarkMetadata->getAfterClassMethods());
     }
 }