public function formatIterationsShortSummary(Variant $variant) { $subject = $variant->getSubject(); $stats = $variant->getStats(); $timeUnit = $this->timeUnit->resolveDestUnit($variant->getSubject()->getOutputTimeUnit()); $mode = $this->timeUnit->resolveMode($subject->getOutputMode()); $precision = $this->timeUnit->resolvePrecision($subject->getOutputTimePrecision()); return sprintf('[μ Mo]/r: %s %s μRSD/r: %s%%', $this->timeUnit->format($stats->getMean(), $timeUnit, $mode, $precision, false), $this->timeUnit->format($stats->getMode(), $timeUnit, $mode, $precision, false), number_format($stats->getRstdev(), 2)); }
/** * {@inheritdoc} */ public function variantEnd(Variant $variant) { if ($variant->hasErrorStack()) { $this->output->write(sprintf("[0G %-30s<error>ERROR</error>", $variant->getSubject()->getName())); $this->output->write(PHP_EOL); return; } $this->output->write(sprintf("\t%s", $this->formatIterationsFullSummary($variant))); $this->output->write(PHP_EOL); }
/** * {@inheritdoc} */ public function variantEnd(Variant $variant) { if ($variant->getRejectCount() > 0) { return; } $subject = $variant->getSubject(); if ($variant->hasErrorStack()) { $this->output->writeln(sprintf(' t%-30s <error>ERROR</error>', $subject->getName())); return; } $this->output->writeln(sprintf(" %-30s I%s P%s\t%s", $subject->getName(), $variant->count(), $variant->getParameterSet()->getIndex(), $this->formatIterationsFullSummary($variant))); }
protected function renderCollectionStatus(Variant $variant) { $this->output->write(PHP_EOL); $this->output->write("[0J"); // 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', $variant->getSubject()->getName()), count($variant), $variant->getRevolutions())); $this->output->write(PHP_EOL); $this->output->write(sprintf('<info>parameters</info> %s', json_encode($variant->getParameterSet()->getArrayCopy(), true))); $this->output->write(PHP_EOL); $this->output->write("[" . 4 . 'A'); // put the cursor back to the line with the measurements $this->output->write("[0G"); // put the cursor back at col 0 }
private function drawIterations(Variant $variant) { $subject = $variant->getSubject(); $this->output->write("[2K"); // clear the whole line $this->output->write(PHP_EOL); $this->output->write("[2K"); // clear the whole line $this->output->write("[1A"); $sigma = 2; $bins = 16; if ($variant->isComputed()) { $times = $variant->getMetricValues(ComputedResult::class, 'z_value'); $stats = $variant->getStats(); $freqs = Statistics::histogram($times, $bins, -$sigma, $sigma); } else { $stats = new Distribution([0]); $freqs = array_fill(0, $bins + 1, null); } $this->output->write(sprintf('#%-2d (σ = %s ) -%sσ [', $subject->getIndex(), $this->timeUnit->format($stats->getStdev()), $sigma)); $this->drawBlocks($freqs, $stats); $this->output->write(sprintf('] +%sσ <comment>%s</comment>', $sigma, $variant->isComputed() ? $this->formatIterationsShortSummary($variant) : '')); $this->output->write(PHP_EOL); }
private function drawIterations(Variant $variant, array $specials, $tag) { $this->output->write("[2K"); // clear line $timeUnit = $variant->getSubject()->getOutputTimeUnit(); $outputMode = $variant->getSubject()->getOutputMode(); $lines = []; $line = sprintf('%-' . self::INDENT . 's', '#' . $variant->getSubject()->getIndex()); $nbIterations = $variant->count(); for ($index = 0; $index < $nbIterations; $index++) { $iteration = $variant->getIteration($index); $displayTime = $this->formatIterationTime($iteration); if (isset($specials[$iteration->getIndex()])) { $displayTime = sprintf('<%s>%' . $this->colWidth . 's</%s>', $tag, $displayTime, $tag); } $line .= $displayTime; if ($index > 0 && $index < $nbIterations - 1 && ($index + 1) % self::NUMBER_COLS == 0) { $lines[] = $line; $line = str_repeat(' ', self::INDENT); } } $lines[] = $line; $this->currentLine = count($lines) - 1; $output = trim(implode(PHP_EOL, $lines)); $output .= sprintf(' (%s)', $this->timeUnit->getDestSuffix($this->timeUnit->resolveDestUnit($timeUnit), $this->timeUnit->resolveMode($outputMode))); $this->output->write(sprintf("%s[0J", $output)); // clear rest of the line }