Пример #1
0
 private function drawIterations(IterationCollection $collection, $specials, $tag, $current = null)
 {
     $subject = $collection->getSubject();
     $timeUnit = $subject->getOutputTimeUnit();
     $outputMode = $subject->getOutputMode();
     $this->output->write("");
     // put cursor at column 0
     $this->output->write(sprintf('#%-2s', $subject->getIndex()));
     $padding = 1;
     $depth = 0;
     for ($index = 0; $index < $collection->count(); $index++) {
         $otherIteration = $collection->getIteration($index);
         $time = 0;
         if ($otherIteration->hasResult()) {
             $time = $otherIteration->getResult()->getTime() / $otherIteration->getRevolutions();
         }
         $displayTime = number_format($this->timeUnit->toDestUnit($time, $this->timeUnit->resolveDestUnit($timeUnit), $this->timeUnit->resolveMode($outputMode)), $this->timeUnit->getPrecision());
         if (strlen($displayTime) > $padding) {
             $padding = strlen($displayTime);
         }
         $output = sprintf('%' . ($padding + 2) . 's', $displayTime);
         if ($current === $index) {
             $output = sprintf('<bg=green>%s</>', $output);
         } elseif (isset($specials[$otherIteration->getIndex()])) {
             $output = sprintf('<%s>%s</%s>', $tag, $output, $tag);
         }
         $this->output->write($output);
         if ($index > 0 && ($index + 1) % self::NUMBER_COLS == 0) {
             $depth++;
             $this->output->write(PHP_EOL);
             $this->output->write('   ');
         }
     }
     $this->depth = $depth;
     $this->output->write(sprintf(' (%s)', $this->timeUnit->getDestSuffix($this->timeUnit->resolveDestUnit($timeUnit), $this->timeUnit->resolveMode($outputMode))));
     $this->output->write("");
     // clear rest of the line
 }
Пример #2
0
 private function drawIterations(IterationCollection $collection, array $specials, $tag)
 {
     $this->output->write("");
     // put cursor at column 0
     $timeUnit = $collection->getSubject()->getOutputTimeUnit();
     $outputMode = $collection->getSubject()->getOutputMode();
     $lines = array();
     $line = sprintf('%-' . self::INDENT . 's', '#' . $collection->getSubject()->getIndex());
     for ($index = 0; $index < $collection->count(); $index++) {
         $iteration = $collection->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 + 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", $output));
     // clear rest of the line
 }