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); } }
/** * {@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); }
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()); } }
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; }
/** * {@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); }
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); } }
/** * {@inheritdoc} */ public function benchmarkStart(Benchmark $benchmark) { $this->output->writeln(sprintf('<comment>%s</comment>', $benchmark->getClass())); $this->output->write(PHP_EOL); }
/** * @param BenchmarkMetadata $benchmark * @param string $name */ public function __construct(Benchmark $benchmark, $name) { $this->benchmark = $benchmark; $this->name = $name; $this->index = count($benchmark->getSubjects()); }
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()); } }