@@ 14-228 (lines=215) @@ | ||
11 | * @Revs(1000) |
|
12 | * @Iterations(20) |
|
13 | */ |
|
14 | class EnumSet32Bench |
|
15 | { |
|
16 | private static $constants; |
|
17 | private static $names; |
|
18 | private static $values; |
|
19 | private static $ordinals; |
|
20 | private static $enumerators; |
|
21 | ||
22 | private $emptySet; |
|
23 | private $fullSet; |
|
24 | ||
25 | public static function initClass() |
|
26 | { |
|
27 | // initialize the enum to make sure the initialization process |
|
28 | // will not effect the benchmark |
|
29 | self::$constants = Enum32::getConstants(); |
|
30 | self::$names = Enum32::getNames(); |
|
31 | self::$values = Enum32::getValues(); |
|
32 | self::$ordinals = Enum32::getOrdinals(); |
|
33 | self::$enumerators = Enum32::getEnumerators(); |
|
34 | } |
|
35 | ||
36 | public function init() |
|
37 | { |
|
38 | $this->emptySet = new EnumSet(Enum32::class); |
|
39 | $this->fullSet = new EnumSet(Enum32::class); |
|
40 | foreach (self::$enumerators as $enumerator) { |
|
41 | $this->fullSet->attach($enumerator); |
|
42 | } |
|
43 | } |
|
44 | ||
45 | public function benchAttachEnumeratorOnEmpty() |
|
46 | { |
|
47 | foreach (self::$enumerators as $enumerator) { |
|
48 | $this->emptySet->attach($enumerator); |
|
49 | } |
|
50 | } |
|
51 | ||
52 | public function benchAttachValueOnEmpty() |
|
53 | { |
|
54 | foreach (self::$values as $value) { |
|
55 | $this->emptySet->attach($value); |
|
56 | } |
|
57 | } |
|
58 | ||
59 | public function benchAttachEnumeratorOnFull() |
|
60 | { |
|
61 | foreach (self::$enumerators as $enumerator) { |
|
62 | $this->fullSet->attach($enumerator); |
|
63 | } |
|
64 | } |
|
65 | ||
66 | public function benchAttachValueOnFull() |
|
67 | { |
|
68 | foreach (self::$values as $value) { |
|
69 | $this->fullSet->attach($value); |
|
70 | } |
|
71 | } |
|
72 | ||
73 | public function benchDetachEnumeratorOnEmpty() |
|
74 | { |
|
75 | foreach (self::$enumerators as $enumerator) { |
|
76 | $this->emptySet->detach($enumerator); |
|
77 | } |
|
78 | } |
|
79 | ||
80 | public function benchDetachValueOnEmpty() |
|
81 | { |
|
82 | foreach (self::$values as $value) { |
|
83 | $this->emptySet->detach($value); |
|
84 | } |
|
85 | } |
|
86 | ||
87 | public function benchDetachEnumeratorOnFull() |
|
88 | { |
|
89 | foreach (self::$enumerators as $enumerator) { |
|
90 | $this->fullSet->detach($enumerator); |
|
91 | } |
|
92 | } |
|
93 | ||
94 | public function benchDetachValueOnFull() |
|
95 | { |
|
96 | foreach (self::$values as $value) { |
|
97 | $this->fullSet->detach($value); |
|
98 | } |
|
99 | } |
|
100 | ||
101 | public function benchContainsEnumeratorTrue() |
|
102 | { |
|
103 | foreach (self::$enumerators as $enumerator) { |
|
104 | $this->fullSet->contains($enumerator); |
|
105 | } |
|
106 | } |
|
107 | ||
108 | public function benchContainsValueTrue() |
|
109 | { |
|
110 | foreach (self::$values as $value) { |
|
111 | $this->fullSet->contains($value); |
|
112 | } |
|
113 | } |
|
114 | ||
115 | public function benchContainsEnumeratorFalse() |
|
116 | { |
|
117 | foreach (self::$enumerators as $enumerator) { |
|
118 | $this->fullSet->contains($enumerator); |
|
119 | } |
|
120 | } |
|
121 | ||
122 | public function benchContainsValueFalse() |
|
123 | { |
|
124 | foreach (self::$values as $value) { |
|
125 | $this->fullSet->contains($value); |
|
126 | } |
|
127 | } |
|
128 | ||
129 | public function benchIterateFull() |
|
130 | { |
|
131 | foreach ($this->fullSet as $enumerator) { |
|
132 | $enumerator->key(); |
|
133 | } |
|
134 | } |
|
135 | ||
136 | public function benchIterateEmpty() |
|
137 | { |
|
138 | foreach ($this->emptySet as $enumerator) { |
|
139 | $enumerator->key(); |
|
140 | } |
|
141 | } |
|
142 | ||
143 | public function benchCountFull() |
|
144 | { |
|
145 | $this->fullSet->count(); |
|
146 | } |
|
147 | ||
148 | public function benchCountEmpty() |
|
149 | { |
|
150 | $this->emptySet->count(); |
|
151 | } |
|
152 | ||
153 | public function benchIsEqual() |
|
154 | { |
|
155 | $this->fullSet->isEqual($this->fullSet); |
|
156 | } |
|
157 | ||
158 | public function benchIsSubset() |
|
159 | { |
|
160 | $this->fullSet->isEqual($this->fullSet); |
|
161 | } |
|
162 | ||
163 | public function benchIsSuperset() |
|
164 | { |
|
165 | $this->fullSet->isSuperset($this->fullSet); |
|
166 | } |
|
167 | ||
168 | public function benchUnion() |
|
169 | { |
|
170 | $this->fullSet->union($this->emptySet); |
|
171 | } |
|
172 | ||
173 | public function benchIntersect() |
|
174 | { |
|
175 | $this->fullSet->intersect($this->emptySet); |
|
176 | } |
|
177 | ||
178 | public function benchDiff() |
|
179 | { |
|
180 | $this->fullSet->diff($this->emptySet); |
|
181 | } |
|
182 | ||
183 | public function benchSymDiff() |
|
184 | { |
|
185 | $this->fullSet->symDiff($this->emptySet); |
|
186 | } |
|
187 | ||
188 | public function benchGetOrdinals() |
|
189 | { |
|
190 | $this->fullSet->getOrdinals(); |
|
191 | } |
|
192 | ||
193 | public function benchGetValues() |
|
194 | { |
|
195 | $this->fullSet->getValues(); |
|
196 | } |
|
197 | ||
198 | public function benchGetNames() |
|
199 | { |
|
200 | $this->fullSet->getNames(); |
|
201 | } |
|
202 | ||
203 | public function benchGetEnumerators() |
|
204 | { |
|
205 | $this->fullSet->getEnumerators(); |
|
206 | } |
|
207 | ||
208 | public function benchGetBit() |
|
209 | { |
|
210 | foreach (self::$ordinals as $ordinal) { |
|
211 | $this->fullSet->getBit($ordinal); |
|
212 | } |
|
213 | } |
|
214 | ||
215 | public function benchSetBit() |
|
216 | { |
|
217 | foreach (self::$ordinals as $ordinal) { |
|
218 | $this->emptySet->setBit($ordinal, true); |
|
219 | } |
|
220 | } |
|
221 | ||
222 | public function benchUnsetBit() |
|
223 | { |
|
224 | foreach (self::$ordinals as $ordinal) { |
|
225 | $this->fullSet->setBit($ordinal, false); |
|
226 | } |
|
227 | } |
|
228 | } |
|
229 |
@@ 14-228 (lines=215) @@ | ||
11 | * @Revs(1000) |
|
12 | * @Iterations(20) |
|
13 | */ |
|
14 | class EnumSet66Bench |
|
15 | { |
|
16 | private static $constants; |
|
17 | private static $names; |
|
18 | private static $values; |
|
19 | private static $ordinals; |
|
20 | private static $enumerators; |
|
21 | ||
22 | private $emptySet; |
|
23 | private $fullSet; |
|
24 | ||
25 | public static function initClass() |
|
26 | { |
|
27 | // initialize the enum to make sure the initialization process |
|
28 | // will not effect the benchmark |
|
29 | self::$constants = Enum66::getConstants(); |
|
30 | self::$names = Enum66::getNames(); |
|
31 | self::$values = Enum66::getValues(); |
|
32 | self::$ordinals = Enum66::getOrdinals(); |
|
33 | self::$enumerators = Enum66::getEnumerators(); |
|
34 | } |
|
35 | ||
36 | public function init() |
|
37 | { |
|
38 | $this->emptySet = new EnumSet(Enum66::class); |
|
39 | $this->fullSet = new EnumSet(Enum66::class); |
|
40 | foreach (self::$enumerators as $enumerator) { |
|
41 | $this->fullSet->attach($enumerator); |
|
42 | } |
|
43 | } |
|
44 | ||
45 | public function benchAttachEnumeratorOnEmpty() |
|
46 | { |
|
47 | foreach (self::$enumerators as $enumerator) { |
|
48 | $this->emptySet->attach($enumerator); |
|
49 | } |
|
50 | } |
|
51 | ||
52 | public function benchAttachValueOnEmpty() |
|
53 | { |
|
54 | foreach (self::$values as $value) { |
|
55 | $this->emptySet->attach($value); |
|
56 | } |
|
57 | } |
|
58 | ||
59 | public function benchAttachEnumeratorOnFull() |
|
60 | { |
|
61 | foreach (self::$enumerators as $enumerator) { |
|
62 | $this->fullSet->attach($enumerator); |
|
63 | } |
|
64 | } |
|
65 | ||
66 | public function benchAttachValueOnFull() |
|
67 | { |
|
68 | foreach (self::$values as $value) { |
|
69 | $this->fullSet->attach($value); |
|
70 | } |
|
71 | } |
|
72 | ||
73 | public function benchDetachEnumeratorOnEmpty() |
|
74 | { |
|
75 | foreach (self::$enumerators as $enumerator) { |
|
76 | $this->emptySet->detach($enumerator); |
|
77 | } |
|
78 | } |
|
79 | ||
80 | public function benchDetachValueOnEmpty() |
|
81 | { |
|
82 | foreach (self::$values as $value) { |
|
83 | $this->emptySet->detach($value); |
|
84 | } |
|
85 | } |
|
86 | ||
87 | public function benchDetachEnumeratorOnFull() |
|
88 | { |
|
89 | foreach (self::$enumerators as $enumerator) { |
|
90 | $this->fullSet->detach($enumerator); |
|
91 | } |
|
92 | } |
|
93 | ||
94 | public function benchDetachValueOnFull() |
|
95 | { |
|
96 | foreach (self::$values as $value) { |
|
97 | $this->fullSet->detach($value); |
|
98 | } |
|
99 | } |
|
100 | ||
101 | public function benchContainsEnumeratorTrue() |
|
102 | { |
|
103 | foreach (self::$enumerators as $enumerator) { |
|
104 | $this->fullSet->contains($enumerator); |
|
105 | } |
|
106 | } |
|
107 | ||
108 | public function benchContainsValueTrue() |
|
109 | { |
|
110 | foreach (self::$values as $value) { |
|
111 | $this->fullSet->contains($value); |
|
112 | } |
|
113 | } |
|
114 | ||
115 | public function benchContainsEnumeratorFalse() |
|
116 | { |
|
117 | foreach (self::$enumerators as $enumerator) { |
|
118 | $this->fullSet->contains($enumerator); |
|
119 | } |
|
120 | } |
|
121 | ||
122 | public function benchContainsValueFalse() |
|
123 | { |
|
124 | foreach (self::$values as $value) { |
|
125 | $this->fullSet->contains($value); |
|
126 | } |
|
127 | } |
|
128 | ||
129 | public function benchIterateFull() |
|
130 | { |
|
131 | foreach ($this->fullSet as $enumerator) { |
|
132 | $enumerator->key(); |
|
133 | } |
|
134 | } |
|
135 | ||
136 | public function benchIterateEmpty() |
|
137 | { |
|
138 | foreach ($this->emptySet as $enumerator) { |
|
139 | $enumerator->key(); |
|
140 | } |
|
141 | } |
|
142 | ||
143 | public function benchCountFull() |
|
144 | { |
|
145 | $this->fullSet->count(); |
|
146 | } |
|
147 | ||
148 | public function benchCountEmpty() |
|
149 | { |
|
150 | $this->emptySet->count(); |
|
151 | } |
|
152 | ||
153 | public function benchIsEqual() |
|
154 | { |
|
155 | $this->fullSet->isEqual($this->fullSet); |
|
156 | } |
|
157 | ||
158 | public function benchIsSubset() |
|
159 | { |
|
160 | $this->fullSet->isEqual($this->fullSet); |
|
161 | } |
|
162 | ||
163 | public function benchIsSuperset() |
|
164 | { |
|
165 | $this->fullSet->isSuperset($this->fullSet); |
|
166 | } |
|
167 | ||
168 | public function benchUnion() |
|
169 | { |
|
170 | $this->fullSet->union($this->emptySet); |
|
171 | } |
|
172 | ||
173 | public function benchIntersect() |
|
174 | { |
|
175 | $this->fullSet->intersect($this->emptySet); |
|
176 | } |
|
177 | ||
178 | public function benchDiff() |
|
179 | { |
|
180 | $this->fullSet->diff($this->emptySet); |
|
181 | } |
|
182 | ||
183 | public function benchSymDiff() |
|
184 | { |
|
185 | $this->fullSet->symDiff($this->emptySet); |
|
186 | } |
|
187 | ||
188 | public function benchGetOrdinals() |
|
189 | { |
|
190 | $this->fullSet->getOrdinals(); |
|
191 | } |
|
192 | ||
193 | public function benchGetValues() |
|
194 | { |
|
195 | $this->fullSet->getValues(); |
|
196 | } |
|
197 | ||
198 | public function benchGetNames() |
|
199 | { |
|
200 | $this->fullSet->getNames(); |
|
201 | } |
|
202 | ||
203 | public function benchGetEnumerators() |
|
204 | { |
|
205 | $this->fullSet->getEnumerators(); |
|
206 | } |
|
207 | ||
208 | public function benchGetBit() |
|
209 | { |
|
210 | foreach (self::$ordinals as $ordinal) { |
|
211 | $this->fullSet->getBit($ordinal); |
|
212 | } |
|
213 | } |
|
214 | ||
215 | public function benchSetBit() |
|
216 | { |
|
217 | foreach (self::$ordinals as $ordinal) { |
|
218 | $this->emptySet->setBit($ordinal, true); |
|
219 | } |
|
220 | } |
|
221 | ||
222 | public function benchUnsetBit() |
|
223 | { |
|
224 | foreach (self::$ordinals as $ordinal) { |
|
225 | $this->fullSet->setBit($ordinal, false); |
|
226 | } |
|
227 | } |
|
228 | } |
|
229 |