PhpBench\Model\Suite::createBenchmark PHP Method

createBenchmark() public method

Create and add a benchmark.
public createBenchmark ( string $class ) : Benchmark
$class string
return Benchmark
    public function createBenchmark($class)
    {
        $benchmark = new Benchmark($this, $class);
        $this->benchmarks[] = $benchmark;
        return $benchmark;
    }

Usage Example

Example #1
0
 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;
 }
All Usage Examples Of PhpBench\Model\Suite::createBenchmark