Passed
Pull Request — master (#506)
by
unknown
02:55
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 chr;
0 ignored issues
show
introduced by
Type chr is not used in this file.
Loading history...
10
use function file_get_contents;
11
12
class UtfStringBench
13
{
14
    /** @var string */
15
    private $testContents;
16
17
    /**
18
     * @BeforeMethods("setUp")
19
     * @Iterations(20)
20
     * @Revs(4)
21
     * @OutputTimeUnit("milliseconds")
22
     * @Assert("mode(variant.time.avg) < 100 milliseconds +/- 10%")
23
     * @Assert("mode(variant.time.avg) > 30 milliseconds +/- 10%")
24
     */
25
    public function benchBuildUtfString(): void
26
    {
27
        $str1 = new UtfString($this->testContents);
28
        for ($i = 0; $i < $str1->length(); $i++) {
29
            $str1[$i];// Make offset offsetGet work
30
        }
31
    }
32
33
    public function setUp(): void
34
    {
35
        $contentsPath = __DIR__ . '/../../LICENSE.txt';
36
        $this->testContents = (string) file_get_contents($contentsPath);
37
    }
38
}
39