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