for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types=1);
namespace Yiisoft\Validator\Tests\Benchmark;
use Generator;
use PhpBench\Benchmark\Metadata\Annotations\Iterations;
use PhpBench\Benchmark\Metadata\Annotations\ParamProviders;
use PhpBench\Benchmark\Metadata\Annotations\Revs;
use ReflectionProperty;
use Yiisoft\Validator\DataSet\ObjectDataSet;
use Yiisoft\Validator\Tests\Support\Data\ObjectWithDifferentPropertyVisibility;
class ObjectDataSetBench
{
private static int $currentPropertyVisibility = ReflectionProperty::IS_PUBLIC;
$currentPropertyVisibility
public function provideObjectDataSets(): Generator
yield 'one instance' => [
'dataSet' => new ObjectDataSet(new ObjectWithDifferentPropertyVisibility()),
];
}
/**
* @Revs(100000)
*
* @Iterations(5)
* @ParamProviders({"provideObjectDataSets"})
*/
public function benchGetRulesWithOneInstance(array $params): void
$dataSet = $params['dataSet'];
$dataSet->getRules();
public function benchGetRulesWithNewInstanceAndCache(): void
$dataSet = new ObjectDataSet(new ObjectWithDifferentPropertyVisibility());