PhpBench\Tests\Util\TestUtil::createSuite PHP Method

createSuite() public static method

public static createSuite ( array $options = [], $suiteIndex = null )
$options array
    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;
    }

Usage Example

示例#1
0
 /**
  * It should delete a specified run and all of its relations.
  */
 public function testDelete()
 {
     $suiteCollection = new SuiteCollection([TestUtil::createSuite(['uuid' => 1234, 'subjects' => ['one', 'two'], 'env' => ['system' => ['os' => 'linux', 'distribution' => 'debian']]])]);
     $this->persister->persist($suiteCollection);
     $counts = $this->getTableCounts();
     $this->assertEquals(['run' => 1, 'subject' => 2, 'variant' => 2, 'parameter' => 1, 'variant_parameter' => 2, 'sgroup_subject' => 6, 'environment' => 2, 'iteration' => 4, 'version' => 1], $counts);
     $this->repository->deleteRun(1234);
     $counts = $this->getTableCounts();
     $this->assertEquals(['run' => 0, 'subject' => 2, 'variant' => 0, 'parameter' => 1, 'variant_parameter' => 0, 'sgroup_subject' => 6, 'environment' => 0, 'iteration' => 0, 'version' => 1], $counts);
 }
All Usage Examples Of PhpBench\Tests\Util\TestUtil::createSuite