Passed
Pull Request — master (#506)
by
unknown
04:51 queued 02:06
created

UtfStringBench::benchGetCharLength()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 19
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 12
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 19
rs 9.8666
1
<?php
2
3
declare(strict_types=1);
4
5
namespace PhpMyAdmin\SqlParser\Tests\benchmarks;
6
7
use PhpMyAdmin\SqlParser\UtfString;
8
9
use function file_get_contents;
10
11
class UtfStringBench
12
{
13
    /** @var string */
14
    private $testContents;
15
16
    /**
17
     * @BeforeMethods("setUp")
18
     * @Iterations(20)
19
     * @Revs(4)
20
     * @OutputTimeUnit("milliseconds")
21
     * @Assert("mode(variant.time.avg) < 100 milliseconds +/- 10%")
22
     * @Assert("mode(variant.time.avg) > 30 milliseconds +/- 10%")
23
     */
24
    public function benchBuildUtfString(): void
25
    {
26
        $str1 = new UtfString($this->testContents);
27
        for ($i = 0; $i < $str1->length(); $i++) {
28
            $str1[$i];// Make offset offsetGet work
29
        }
30
    }
31
32
    public function setUp(): void
33
    {
34
        $contentsPath = __DIR__ . '/../../LICENSE.txt';
35
        $this->testContents = (string) file_get_contents($contentsPath);
36
    }
37
}
38