/
ZendMmBinsInfo.php
144 lines (133 loc) · 2.58 KB
/
ZendMmBinsInfo.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
<?php
/**
* This file is part of the reliforp/reli-prof package.
*
* (c) sji <sji@sj-i.dev>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Reli\Lib\PhpInternals\Types\Zend;
class ZendMmBinsInfo
{
private const SIZES = [
0 => 8,
1 => 16,
2 => 24,
3 => 32,
4 => 40,
5 => 48,
6 => 56,
7 => 64,
8 => 80,
9 => 96,
10 => 112,
11 => 128,
12 => 160,
13 => 192,
14 => 224,
15 => 256,
16 => 320,
17 => 384,
18 => 448,
19 => 512,
20 => 640,
21 => 768,
22 => 896,
23 => 1024,
24 => 1280,
25 => 1536,
26 => 1792,
27 => 2048,
28 => 2560,
29 => 3072,
];
private const COUNTS = [
0 => 512,
1 => 256,
2 => 170,
3 => 128,
4 => 102,
5 => 85,
6 => 73,
7 => 64,
8 => 51,
9 => 42,
10 => 36,
11 => 32,
12 => 25,
13 => 21,
14 => 18,
15 => 16,
16 => 64,
17 => 32,
18 => 9,
19 => 8,
20 => 32,
21 => 16,
22 => 9,
23 => 8,
24 => 16,
25 => 8,
26 => 16,
27 => 8,
28 => 8,
29 => 4,
];
private const PAGES = [
0 => 1,
1 => 1,
2 => 1,
3 => 1,
4 => 1,
5 => 1,
6 => 1,
7 => 1,
8 => 1,
9 => 1,
10 => 1,
11 => 1,
12 => 1,
13 => 1,
14 => 1,
15 => 1,
16 => 5,
17 => 3,
18 => 1,
19 => 1,
20 => 5,
21 => 3,
22 => 2,
23 => 2,
24 => 5,
25 => 3,
26 => 7,
27 => 4,
28 => 5,
29 => 3,
];
public static function getSize(int $bin_num): int
{
return self::SIZES[$bin_num];
}
public static function getCount(int $bin_num): int
{
return self::COUNTS[$bin_num];
}
public static function getPages(int $bin_num): int
{
return self::PAGES[$bin_num];
}
public static function sizeToBinNum(int $size): int
{
$bin_num = 0;
while (self::SIZES[$bin_num] < $size) {
++$bin_num;
if ($bin_num >= 30) {
throw new \RuntimeException('invalid size');
}
}
return $bin_num;
}
}