public static function filenameFromIteration(Iteration $iteration, $extension = '') { $name = sprintf('%s::%s.P%s%s', $iteration->getVariant()->getSubject()->getBenchmark()->getClass(), $iteration->getVariant()->getSubject()->getName(), $iteration->getVariant()->getParameterSet()->getIndex(), $extension); $name = str_replace('\\', '_', $name); $name = str_replace('/', '_', $name); return $name; }
public function iterationStart(Iteration $iteration) { if ($this->isCi) { return; } $state = $iteration->getIndex() % 4; $states = [0 => '|', 1 => '/', 2 => '-', 3 => '\\']; $this->output->write(sprintf("\r%s%s", $this->buffer, $states[$state])); }
/** * {@inheritdoc} */ public function launch(Payload $payload, Iteration $iteration, Config $options) { $phpConfig = ['max_execution_time' => 0]; $payload->setPhpConfig($phpConfig); $result = $payload->launch(); if (isset($result['buffer']) && $result['buffer']) { throw new \RuntimeException(sprintf('Benchmark made some noise: %s', $result['buffer'])); } $iteration->setResult(new TimeResult($result['time'])); $iteration->setResult(MemoryResult::fromArray($result['mem'])); }
protected function formatIterationTime(Iteration $iteration) { $subject = $iteration->getVariant()->getSubject(); $timeUnit = $subject->getOutputTimeUnit(); $outputMode = $subject->getOutputMode(); $time = 0; if ($iteration->hasResult(TimeResult::class)) { $time = $iteration->getResult(TimeResult::class)->getRevTime($iteration->getVariant()->getRevolutions()); } return number_format($this->timeUnit->toDestUnit($time, $this->timeUnit->resolveDestUnit($timeUnit), $this->timeUnit->resolveMode($outputMode)), $this->timeUnit->resolvePrecision($subject->getOutputTimePrecision())); }
/** * {@inheritdoc} */ public function execute(SubjectMetadata $subjectMetadata, Iteration $iteration, Config $config) { // add 100 bytes of memory. $memory = 100; $iteration->setResult(new MemoryResult($memory, $memory, $memory)); if (!$config['times']) { $iteration->setResult(new TimeResult(0)); return; } $variantHash = spl_object_hash($iteration->getVariant()); if (!isset($this->variantTimes[$variantHash])) { $this->variantTimes[$variantHash] = $config['times']; } if (!isset($this->variantTimes[$variantHash][$this->index])) { $this->index = 0; } $time = $this->variantTimes[$variantHash][$this->index]; $this->index++; if ($config['spread']) { $index = $iteration->getIndex() % count($config['spread']); $spreadDiff = $config['spread'][$index]; $time = $time + $spreadDiff; } $iteration->setResult(new TimeResult($time)); }
/** * {@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->getVariant()->count(), $iteration->getVariant()->getRejectCount())); $this->output->write("[2A"); $this->output->write("[0G"); }
/** * It should return the revolution time. */ public function testGetRevTime() { $iteration = new Iteration(1, $this->variant->reveal(), TestUtil::createResults(100)); $this->variant->getRevolutions()->willReturn(100); $this->assertEquals(1, $iteration->getResult(TimeResult::class)->getRevTime(100)); }
/** * {@inheritdoc} */ public function iterationStart(Iteration $iteration) { $this->output->write(sprintf("[0G %-30s%sI%s P%s ", $iteration->getVariant()->getSubject()->getName(), $this->rejectionCount ? 'R' . $this->rejectionCount . ' ' : '', $iteration->getIndex(), $iteration->getVariant()->getParameterSet()->getIndex())); }
private function getYPos(Iteration $iteration) { return floor($iteration->getIndex() / self::NUMBER_COLS); }
/** * {@inheritdoc} */ public function execute(SubjectMetadata $subjectMetadata, Iteration $iteration, Config $config) { $tokens = ['class' => $subjectMetadata->getBenchmark()->getClass(), 'file' => $subjectMetadata->getBenchmark()->getPath(), 'subject' => $subjectMetadata->getName(), 'revolutions' => $iteration->getVariant()->getRevolutions(), 'beforeMethods' => var_export($subjectMetadata->getBeforeMethods(), true), 'afterMethods' => var_export($subjectMetadata->getAfterMethods(), true), 'parameters' => var_export($iteration->getVariant()->getParameterSet()->getArrayCopy(), true), 'warmup' => $iteration->getVariant()->getWarmup() ?: 0]; $payload = $this->launcher->payload(__DIR__ . '/template/microtime.template', $tokens); return $this->launch($payload, $iteration, $config); }