createBenchmark() public method

Create and add a benchmark.
public createBenchmark ( string $class ) : Benchmark
$class string
return Benchmark
コード例 #1
0
ファイル: TestUtil.php プロジェクト: dantleech/phpbench
 public static function createSuite(array $options = [], $suiteIndex = null)
 {
     $options = array_merge(['uuid' => $suiteIndex, 'date' => '2016-02-06', 'revs' => 5, 'warmup' => 10, 'sleep' => 1, 'basetime' => 10, 'groups' => [], 'name' => 'test', 'benchmarks' => ['TestBench'], 'groups' => ['one', 'two', 'three'], 'parameters' => ['param1' => 'value1'], 'subjects' => ['benchOne'], 'env' => [], 'output_time_unit' => 'microseconds', 'output_time_precision' => 7, 'output_mode' => 'time', 'iterations' => [0, 10]], $options);
     $dateTime = new \DateTime($options['date']);
     $suite = new Suite($options['name'], $dateTime, null, [], [], $options['uuid']);
     foreach ($options['benchmarks'] as $benchmarkClass) {
         $benchmark = $suite->createBenchmark($benchmarkClass);
         $baseTime = $options['basetime'];
         foreach ($options['subjects'] as $subjectName) {
             $subject = $benchmark->createSubject($subjectName);
             $subject->setSleep($options['sleep']);
             $subject->setGroups($options['groups']);
             $subject->setOutputTimeUnit($options['output_time_unit']);
             $subject->setOutputTimePrecision($options['output_time_precision']);
             $subject->setOutputMode($options['output_mode']);
             $variant = $subject->createVariant(new ParameterSet(0, $options['parameters']), $options['revs'], $options['warmup']);
             $time = $baseTime;
             foreach ($options['iterations'] as $time) {
                 $variant->createIteration(self::createResults($baseTime + $time, 200, 0));
             }
             $variant->computeStats();
             $baseTime++;
         }
     }
     $informations = [];
     foreach ($options['env'] as $name => $information) {
         $informations[] = new Information($name, $information);
     }
     $suite->setEnvInformations($informations);
     return $suite;
 }
コード例 #2
0
ファイル: Loader.php プロジェクト: dantleech/phpbench
 private function getBenchmark(\ArrayObject $context, Suite $suite, array $row)
 {
     $key = $row['run.uuid'] . $row['subject.benchmark'];
     if (isset($context[self::BENCHMARKS][$key])) {
         return $context[self::BENCHMARKS][$key];
     }
     $benchmark = $suite->createBenchmark($row['subject.benchmark']);
     $context[self::BENCHMARKS][$key] = $benchmark;
     return $benchmark;
 }
コード例 #3
0
ファイル: XmlDecoder.php プロジェクト: dantleech/phpbench
 private function processSuite(\DOMElement $suiteEl)
 {
     $suite = new Suite($suiteEl->getAttribute('context'), new \DateTime($suiteEl->getAttribute('date')), $suiteEl->getAttribute('config-path'), [], [], $suiteEl->getAttribute('uuid'));
     $informations = [];
     foreach ($suiteEl->query('./env/*') as $envEl) {
         $name = $envEl->nodeName;
         $info = [];
         foreach ($envEl->attributes as $iName => $valueAttr) {
             $info[$iName] = $valueAttr->nodeValue;
         }
         $informations[$name] = new Information($name, $info);
     }
     $resultClasses = [];
     foreach ($suiteEl->query('//result') as $resultEl) {
         $class = $resultEl->getAttribute('class');
         if (!class_exists($class)) {
             throw new \RuntimeException(sprintf('XML file defines a non-existing result class "%s" - maybe you are missing an extension?', $class));
         }
         $resultClasses[$resultEl->getAttribute('key')] = $class;
     }
     $suite->setEnvInformations($informations);
     foreach ($suiteEl->query('./benchmark') as $benchmarkEl) {
         $benchmark = $suite->createBenchmark($benchmarkEl->getAttribute('class'));
         $this->processBenchmark($benchmark, $benchmarkEl, $resultClasses);
     }
     return $suite;
 }