PhpBench\Extensions\XDebug\Command\ProfileCommand::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)
    {
        $outputDir = $this->outputDirHandler->handleOutputDir($input, $output);
        $guiBin = null;
        if ($input->getOption('gui')) {
            $finder = new ExecutableFinder();
            $guiBin = $finder->find($input->getOption('gui-bin'));
            if (null === $guiBin) {
                throw new \InvalidArgumentException(sprintf('Could not locate GUI bin "%s"', $input->getOption('gui-bin')));
            }
        }
        $generatedFiles = [];
        $this->runnerHandler->runFromInput($input, $output, ['executor' => ['executor' => 'xdebug_profile', 'output_dir' => $outputDir, 'callback' => function ($iteration) use($outputDir, $guiBin, &$generatedFiles) {
            $generatedFiles[] = $generatedFile = $outputDir . DIRECTORY_SEPARATOR . XDebugUtil::filenameFromIteration($iteration, '.cachegrind');
            if ($guiBin) {
                $process = new Process(sprintf($guiBin . ' ' . $generatedFile));
                $process->run();
            }
        }], 'iterations' => [1]]);
        $output->write(PHP_EOL);
        $output->writeln(sprintf('<info>%s profile(s) generated:</info>', count($generatedFiles)));
        $output->write(PHP_EOL);
        foreach ($generatedFiles as $generatedFile) {
            if (!file_exists($generatedFile)) {
                throw new \InvalidArgumentException(sprintf('Profile "%s" was not generated. Maybe you do not have XDebug installed?', $generatedFile));
            }
            $output->writeln(sprintf('    %s', $generatedFile));
        }
    }