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

SplIntBench::benchMath()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
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 9
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\SplInt as DuckInt;
17
18
class SplIntBench
19
{
20
    /**
21
     * @Revs(1000)
22
     *
23
     * @Iterations(5)
24
     *
25
     * @return void
26
     */
27
    public function benchCreateZero(): void
28
    {
29
        new DuckInt();
30
    }
31
32
    /**
33
     * @Revs(1000)
34
     *
35
     * @Iterations(5)
36
     *
37
     * @return void
38
     */
39
    public function benchCreateRand(): void
40
    {
41
        new DuckInt(mt_rand());
42
    }
43
44
    /**
45
     * @Revs(1000)
46
     *
47
     * @Iterations(5)
48
     *
49
     * @return void
50
     */
51
    public function benchCreateMin(): void
52
    {
53
        new DuckInt(PHP_INT_MIN);
54
    }
55
56
    /**
57
     * @Revs(1000)
58
     *
59
     * @Iterations(5)
60
     *
61
     * @return void
62
     */
63
    public function benchCreateMax(): void
64
    {
65
        new DuckInt(PHP_INT_MAX);
66
    }
67
68
    /**
69
     * @Revs(1000)
70
     *
71
     * @Iterations(5)
72
     *
73
     * @return void
74
     *
75
     * @psalm-suppress UnsupportedReferenceUsage
76
     */
77
    public function benchMath(): void
78
    {
79
        $instance = new DuckInt(10);
80
81
        $value = &$instance();
82
        $value++;
83
84
        $result = $value;
85
        unset($result);
86
    }
87
}
88