Code Duplication    Length = 226-226 lines in 2 locations

bench/EnumSet32Bench.php 1 location

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

bench/EnumSet66Bench.php 1 location

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