1 | <?php |
||
2 | |||
3 | declare(strict_types=1); |
||
4 | |||
5 | namespace Yiisoft\Validator\Tests\Benchmark; |
||
6 | |||
7 | use Generator; |
||
8 | use PhpBench\Benchmark\Metadata\Annotations\Iterations; |
||
9 | use PhpBench\Benchmark\Metadata\Annotations\ParamProviders; |
||
10 | use PhpBench\Benchmark\Metadata\Annotations\Revs; |
||
11 | use ReflectionProperty; |
||
12 | use Yiisoft\Validator\DataSet\ObjectDataSet; |
||
13 | use Yiisoft\Validator\Tests\Support\Data\ObjectWithDifferentPropertyVisibility; |
||
14 | |||
15 | class ObjectDataSetBench |
||
16 | { |
||
17 | private static int $currentPropertyVisibility = ReflectionProperty::IS_PUBLIC; |
||
0 ignored issues
–
show
introduced
by
![]() |
|||
18 | |||
19 | public function provideObjectDataSets(): Generator |
||
20 | { |
||
21 | yield 'one instance' => [ |
||
22 | 'dataSet' => new ObjectDataSet(new ObjectWithDifferentPropertyVisibility()), |
||
23 | ]; |
||
24 | } |
||
25 | |||
26 | /** |
||
27 | * @Revs(100000) |
||
28 | * |
||
29 | * @Iterations(5) |
||
30 | * |
||
31 | * @ParamProviders({"provideObjectDataSets"}) |
||
32 | */ |
||
33 | public function benchGetRulesWithOneInstance(array $params): void |
||
34 | { |
||
35 | $dataSet = $params['dataSet']; |
||
36 | $dataSet->getRules(); |
||
37 | } |
||
38 | |||
39 | /** |
||
40 | * @Revs(100000) |
||
41 | * |
||
42 | * @Iterations(5) |
||
43 | */ |
||
44 | public function benchGetRulesWithNewInstanceAndCache(): void |
||
45 | { |
||
46 | $dataSet = new ObjectDataSet(new ObjectWithDifferentPropertyVisibility()); |
||
47 | $dataSet->getRules(); |
||
48 | } |
||
49 | } |
||
50 |