Passed
Push — master ( 350129...e9e39b )
by PHPinnacle
02:11
created

ReadBench::benchRead()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 18
Code Lines 16

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 16
nc 1
nop 0
dl 0
loc 18
rs 9.7333
c 0
b 0
f 0
1
<?php
2
3
use PHPinnacle\Buffer\ByteBuffer;
4
5
/**
6
 * @BeforeMethods({"init"})
7
 */
8
class ReadBench
9
{
10
    /**
11
     * @var ByteBuffer
12
     */
13
    private $buffer;
14
15
    /**
16
     * @return void
17
     */
18
    public function init(): void
19
    {
20
        $this->buffer = new ByteBuffer;
21
        $this->buffer
22
            ->appendInt8(1)
23
            ->appendInt16(1)
24
            ->appendInt32(1)
25
            ->appendInt64(1)
26
            ->appendUint8(1)
27
            ->appendUint16(1)
28
            ->appendUint32(1)
29
            ->appendUint64(1)
30
            ->appendFloat(1.1)
31
            ->appendFloat(-1.1)
32
            ->appendFloat(\M_PI)
33
            ->appendDouble(1.1)
34
            ->appendDouble(-1.1)
35
            ->appendDouble(\M_PI)
36
            ->append('some string')
37
            ->append("other string")
38
        ;
39
    }
40
41
    /**
42
     * @Revs(1000)
43
     * @Iterations(100)
44
     *
45
     * @return void
46
     */
47
    public function benchRead(): void
48
    {
49
        $this->buffer->readInt8();
50
        $this->buffer->readInt16(1);
51
        $this->buffer->readInt32(3);
52
        $this->buffer->readInt64(7);
53
        $this->buffer->readUint8(15);
54
        $this->buffer->readUint16(16);
55
        $this->buffer->readUint32(18);
56
        $this->buffer->readUint64(22);
57
        $this->buffer->readFloat(30);
58
        $this->buffer->readFloat(34);
59
        $this->buffer->readFloat(38);
60
        $this->buffer->readDouble(42);
61
        $this->buffer->readDouble(50);
62
        $this->buffer->readDouble(58);
63
        $this->buffer->read(11, 66);
64
        $this->buffer->read(12, 77);
65
    }
66
}
67