PhpBench\Console\Command\LogCommand::execute PHP Метод

execute() публичный Метод

public execute ( Symfony\Component\Console\Input\InputInterface $input, Symfony\Component\Console\Output\OutputInterface $output )
$input Symfony\Component\Console\Input\InputInterface
$output Symfony\Component\Console\Output\OutputInterface
    public function execute(InputInterface $input, OutputInterface $output)
    {
        $this->timeUnitHandler->timeUnitFromInput($input);
        $paginate = false === $input->getOption('no-pagination');
        // if we have an application, get the terminal dimensions, if the
        // terminal dimensions are null then set the height to the arbitrary
        // value of 100.
        $height = 100;
        if ($application = $this->getApplication()) {
            list($width, $height) = $application->getTerminalDimensions();
            $height = $height ?: 100;
        }
        $height -= 1;
        // reduce height by one to accomodate the pagination prompt
        $nbRows = 0;
        $totalRows = 0;
        foreach ($this->storage->getService()->history() as $entry) {
            $lines = [];
            $lines[] = sprintf('<comment>run %s</>', $entry->getRunId());
            $lines[] = sprintf('Date:    ' . $entry->getDate()->format('c'));
            $lines[] = sprintf('Branch:  ' . $entry->getVcsBranch());
            $lines[] = sprintf('Context: ' . ($entry->getContext() ?: '<none>'));
            $lines[] = sprintf('Scale:   ' . '%d subjects, %d iterations, %d revolutions', $entry->getNbSubjects(), $entry->getNbIterations(), $entry->getNbRevolutions());
            $lines[] = sprintf('Summary: (best [mean] worst) = %s [%s] %s (%s)', number_format($this->timeUnit->toDestUnit($entry->getMinTime()), 3), number_format($this->timeUnit->toDestUnit($entry->getMeanTime()), 3), number_format($this->timeUnit->toDestUnit($entry->getMaxTime()), 3), $this->timeUnit->getDestSuffix());
            $lines[] = sprintf('         ⅀T: %s μRSD/r: %s%%', $this->timeUnit->format($entry->getTotalTime(), null, TimeUnit::MODE_TIME), number_format($entry->getMeanRelStDev(), 3));
            $lines[] = '';
            $nbRows = $this->writeLines($output, $nbRows, $height, $lines);
            // if pagination is diabled, then just pretend that the console height
            // is always greater than the number of rows.
            if (false === $paginate) {
                $height += $nbRows;
            }
            if ($paginate && $nbRows >= $height) {
                $output->write(sprintf('<question>lines %s-%s any key to continue, <q> to quit</question>', $totalRows, $totalRows + $nbRows));
                $character = $this->characterReader->read();
                if ($character == 'q') {
                    break;
                }
                $output->write(PHP_EOL);
                $totalRows += $nbRows;
                $nbRows = 0;
            }
        }
    }