PhpBench\Extensions\XDebug\XDebugUtil::filenameFromIteration PHP Method

filenameFromIteration() public static method

public static filenameFromIteration ( Iteration $iteration, $extension = '' )
$iteration PhpBench\Model\Iteration
    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;
    }

Usage Example

Example #1
0
 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));
     }
 }
All Usage Examples Of PhpBench\Extensions\XDebug\XDebugUtil::filenameFromIteration