ObjectDataSetBench::provideObjectDataSets()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 4
rs 10
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
The private property $currentPropertyVisibility is not used, and could be removed.
Loading history...
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