Passed
Push — 7.x ( 3ebc9f...4982c4 )
by Adrien
08:52
created

SplStringBench::benchConcatenate()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 5
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 8
rs 10
1
<?php
2
3
/**
4
 * Part of SplTypes package.
5
 *
6
 * (c) Adrien Loyant <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
declare(strict_types=1);
13
14
namespace Ducks\Component\SplTypes\Tests\benchmark;
15
16
use Ducks\Component\SplTypes\SplString as DuckString;
17
18
class SplStringBench
19
{
20
    /**
21
     * @Revs(1000)
22
     *
23
     * @Iterations(5)
24
     *
25
     * @return void
26
     */
27
    public function benchCreateEmpty(): void
28
    {
29
        new DuckString();
30
    }
31
32
    /**
33
     * @Revs(1000)
34
     *
35
     * @Iterations(5)
36
     *
37
     * @return void
38
     */
39
    public function benchCreateTest(): void
40
    {
41
        new DuckString('test');
42
    }
43
44
    /**
45
     * @Revs(1000)
46
     *
47
     * @Iterations(5)
48
     *
49
     * @return void
50
     */
51
    public function benchCreateNumeric(): void
52
    {
53
        new DuckString((string) mt_rand());
54
    }
55
56
    /**
57
     * @Revs(1000)
58
     *
59
     * @Iterations(5)
60
     *
61
     * @return void
62
     *
63
     * @psalm-suppress UnsupportedReferenceUsage
64
     */
65
    public function benchConcatenate(): void
66
    {
67
        $string = new DuckString('hello ');
68
        $value = &$string();
69
        $value .= 'world';
70
71
        $result = $value;
72
        unset($result);
73
    }
74
}
75