public function getContextName() { return $this->options['context_name']; }
/** * Run all benchmarks (or all applicable benchmarks) in the given path. * * The $name argument will set the "name" attribute on the "suite" element. * * @param string $contextName * @param string $path */ public function run(RunnerContext $context) { $executorConfig = $this->executorRegistry->getConfig($context->getExecutor()); $executor = $this->executorRegistry->getService($executorConfig['executor']); $dom = new SuiteDocument(); $rootEl = $dom->createElement('phpbench'); $rootEl->setAttribute('version', PhpBench::VERSION); $dom->appendChild($rootEl); $suiteEl = $rootEl->appendElement('suite'); $suiteEl->setAttribute('context', $context->getContextName()); $suiteEl->setAttribute('date', date('c')); $suiteEl->setAttribute('config-path', $this->configPath); $suiteEl->setAttribute('retry-threshold', $context->getRetryThreshold($this->retryThreshold)); // add environmental information. $this->appendEnvironment($suiteEl); // build the collection of benchmarks to be executed. $collection = $this->collectionBuilder->buildCollection($context->getPath(), $context->getFilters(), $context->getGroups()); // log the start of the suite run. $this->logger->startSuite($dom); /* @var BenchmarkMetadata */ foreach ($collection->getBenchmarks() as $benchmark) { $benchmarkEl = $dom->createElement('benchmark'); $benchmarkEl->setAttribute('class', $benchmark->getClass()); $this->logger->benchmarkStart($benchmark); $this->runBenchmark($executor, $context, $benchmark, $benchmarkEl); $this->logger->benchmarkEnd($benchmark); $suiteEl->appendChild($benchmarkEl); } $this->logger->endSuite($dom); return $dom; }