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

SplFloatBench   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 68
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 10
c 1
b 0
f 1
dl 0
loc 68
rs 10
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A benchCreateZero() 0 3 1
A benchCreateRand() 0 3 1
A benchCreateMin() 0 3 1
A benchCreateMax() 0 3 1
A benchMath() 0 9 1
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\SplFloat as DuckFloat;
17
18
class SplFloatBench
19
{
20
    /**
21
     * @Revs(1000)
22
     *
23
     * @Iterations(5)
24
     *
25
     * @return void
26
     */
27
    public function benchCreateZero(): void
28
    {
29
        new DuckFloat();
30
    }
31
32
    /**
33
     * @Revs(1000)
34
     *
35
     * @Iterations(5)
36
     *
37
     * @return void
38
     */
39
    public function benchCreateRand(): void
40
    {
41
        new DuckFloat((float) 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 DuckFloat(PHP_FLOAT_MIN);
54
    }
55
56
    /**
57
     * @Revs(1000)
58
     *
59
     * @Iterations(5)
60
     *
61
     * @return void
62
     */
63
    public function benchCreateMax(): void
64
    {
65
        new DuckFloat(PHP_FLOAT_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 DuckFloat(10.1);
80
81
        $value = &$instance();
82
        $value++;
83
84
        $result = $value;
85
        unset($result);
86
    }
87
}
88