Total Complexity | 5 |
Total Lines | 74 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
9 | class BufferWriteBench |
||
10 | { |
||
11 | /** |
||
12 | * @var ByteBuffer |
||
13 | */ |
||
14 | private $buffer; |
||
15 | |||
16 | /** |
||
17 | * @return void |
||
18 | */ |
||
19 | public function init(): void |
||
20 | { |
||
21 | $this->buffer = new ByteBuffer(); |
||
22 | } |
||
23 | |||
24 | /** |
||
25 | * @Revs(5) |
||
26 | * @Iterations(100) |
||
27 | * |
||
28 | * @return void |
||
29 | */ |
||
30 | public function benchAppendIntegers(): void |
||
31 | { |
||
32 | $this->buffer |
||
33 | ->appendInt8(1) |
||
34 | ->appendInt16(1) |
||
35 | ->appendInt32(1) |
||
36 | ->appendInt64(1) |
||
37 | ->appendUint8(1) |
||
38 | ->appendUint16(1) |
||
39 | ->appendUint32(1) |
||
40 | ->appendUint64(1) |
||
41 | ; |
||
42 | } |
||
43 | |||
44 | /** |
||
45 | * @Revs(5) |
||
46 | * @Iterations(100) |
||
47 | * |
||
48 | * @return void |
||
49 | */ |
||
50 | public function benchAppendFloats(): void |
||
51 | { |
||
52 | $this->buffer |
||
53 | ->appendFloat(1.0) |
||
54 | ->appendFloat(-1.0) |
||
55 | ->appendFloat(\M_PI) |
||
56 | ->appendDouble(1.0) |
||
57 | ->appendDouble(-1.0) |
||
58 | ->appendDouble(\M_PI) |
||
59 | ; |
||
60 | } |
||
61 | |||
62 | /** |
||
63 | * @Revs(5) |
||
64 | * @Iterations(100) |
||
65 | * |
||
66 | * @return void |
||
67 | */ |
||
68 | public function benchAppendString(): void |
||
69 | { |
||
70 | $this->buffer |
||
71 | ->append('some string') |
||
72 | ->append("other string") |
||
73 | ->append(str_repeat('str', 1000)) |
||
74 | ; |
||
75 | } |
||
76 | |||
77 | /** |
||
78 | * @return void |
||
79 | */ |
||
80 | public function clear(): void |
||
83 | } |
||
84 | } |
||
85 |