radius-spec 0.4.0 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5,7 +5,7 @@ require_relative 'bm_setup'
5
5
 
6
6
  display_benchmark_header
7
7
 
8
- INT_RANGE = (0..15)
8
+ INT_RANGE = (0..15).freeze
9
9
  INT_VAR = 10
10
10
 
11
11
  section "Integer ranges" do |bench|
@@ -30,7 +30,7 @@ BEGIN_OF_JULY = Time.utc(2015, 7, 1)
30
30
  END_OF_JULY = Time.utc(2015, 7, 31)
31
31
  DAY_IN_JULY = Time.utc(2015, 7, 15)
32
32
 
33
- TIME_RANGE = (BEGIN_OF_JULY..END_OF_JULY)
33
+ TIME_RANGE = (BEGIN_OF_JULY..END_OF_JULY).freeze
34
34
 
35
35
  section "Time ranges" do |bench|
36
36
  bench.report('range#cover?') do
@@ -15,15 +15,15 @@ MULTI_TOKEN_HASH = {
15
15
  # rubocop:disable Style/FormatString
16
16
  section "Format String" do |bench|
17
17
  bench.report("String#%") do
18
- '%10s' % 'hoge'
18
+ '%10s' % 'hoge' # rubocop:disable Style/FormatStringToken
19
19
  end
20
20
 
21
21
  bench.report("format") do
22
- format '%10s', 'hoge'
22
+ format '%10s', 'hoge' # rubocop:disable Style/FormatStringToken
23
23
  end
24
24
 
25
25
  bench.report("sprintf") do
26
- sprintf '%10s', 'hoge'
26
+ sprintf '%10s', 'hoge' # rubocop:disable Style/FormatStringToken
27
27
  end
28
28
  end
29
29
  # rubocop:enable Style/FormatString
@@ -0,0 +1,305 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Run from the command line: bundle exec ruby benchmarks/hash_merge.rb
4
+ require_relative 'bm_setup'
5
+
6
+ # rubocop:disable Style/HashEachMethods
7
+
8
+ display_benchmark_header
9
+
10
+ # Bad per Rubocop
11
+ def hash_keys_each(hash)
12
+ hash.keys.each { |k| k + 1 }
13
+
14
+ # Return nil to avoid array creation penalty which may skew benchmark
15
+ nil
16
+ end
17
+
18
+ # Good per Rubocop
19
+ def hash_each_key(hash)
20
+ hash.each_key { |k| k + 1 }
21
+
22
+ # Return nil to avoid array creation penalty which may skew benchmark
23
+ nil
24
+ end
25
+
26
+ [
27
+ [],
28
+ (1..5),
29
+ (1..10),
30
+ (1..20),
31
+ (1..100),
32
+ (1..500),
33
+ ].each do |data|
34
+ test_hash = data.zip(data).to_h
35
+
36
+ section "Hash key enumeration (size=#{data.size})" do |bench|
37
+ bench.report("Hash.keys.each") do
38
+ hash_keys_each(test_hash)
39
+ end
40
+
41
+ bench.report("Hash.each_key") do
42
+ hash_each_key(test_hash)
43
+ end
44
+ end
45
+ end
46
+
47
+ # Bad per Rubocop
48
+ def hash_values_each(hash)
49
+ hash.values.each { |v| v + 1 }
50
+
51
+ # Return nil to avoid array creation penalty which may skew benchmark
52
+ nil
53
+ end
54
+
55
+ # Good per Rubocop
56
+ def hash_each_value(hash)
57
+ hash.each_value { |v| v + 1 }
58
+
59
+ # Return nil to avoid array creation penalty which may skew benchmark
60
+ nil
61
+ end
62
+
63
+ [
64
+ [],
65
+ (1..5),
66
+ (1..10),
67
+ (1..20),
68
+ (1..100),
69
+ (1..500),
70
+ ].each do |data|
71
+ test_hash = data.zip(data).to_h
72
+
73
+ section "Hash value enumeration (size=#{data.size})" do |bench|
74
+ bench.report("Hash.values.each") do
75
+ hash_values_each(test_hash)
76
+ end
77
+
78
+ bench.report("Hash.each_value") do
79
+ hash_each_value(test_hash)
80
+ end
81
+ end
82
+ end
83
+
84
+ # rubocop:enable Style/HashEachMethods
85
+
86
+ __END__
87
+
88
+ ### Environment
89
+
90
+ Heroku Performance-L Dyno
91
+
92
+ ruby 2.7.3p183 (2021-04-05 revision 6847ee089d) [x86_64-linux]
93
+ GC Disabled: false
94
+
95
+ ### Test Cases
96
+
97
+ Behavior for the keys and value enumerations is roughly equivalent. As
98
+ hypothesized the `each_xyz` versions are faster. What is surprising is that the
99
+ performance difference drops off drastically the larger the hash, even for
100
+ small hash sizes. Basically, once the hash reaches 10 times, the performance
101
+ gains are constant after that point (around 1 - 4%).
102
+
103
+ #### Hash key enumeration (size=0)
104
+
105
+ ```
106
+ Warming up --------------------------------------
107
+ Hash.keys.each 913.942k i/100ms
108
+ Hash.each_key 1.376M i/100ms
109
+ Calculating -------------------------------------
110
+ Hash.keys.each 9.167M (± 0.0%) i/s - 46.611M in 5.084564s
111
+ Hash.each_key 13.734M (± 0.2%) i/s - 68.779M in 5.008581s
112
+ with 95.0% confidence
113
+
114
+ Comparison:
115
+ Hash.each_key: 13734476.7 i/s
116
+ Hash.keys.each: 9167168.9 i/s - 1.50x (± 0.00) slower
117
+ with 95.0% confidence
118
+ ```
119
+
120
+ #### Hash key enumeration (size=5)
121
+
122
+ ```
123
+ Warming up --------------------------------------
124
+ Hash.keys.each 319.678k i/100ms
125
+ Hash.each_key 360.081k i/100ms
126
+ Calculating -------------------------------------
127
+ Hash.keys.each 3.190M (± 0.4%) i/s - 15.984M in 5.012434s
128
+ Hash.each_key 3.596M (± 0.0%) i/s - 18.004M in 5.006636s
129
+ with 95.0% confidence
130
+
131
+ Comparison:
132
+ Hash.each_key: 3596043.0 i/s
133
+ Hash.keys.each: 3189893.5 i/s - 1.13x (± 0.00) slower
134
+ with 95.0% confidence
135
+ ```
136
+
137
+ #### Hash key enumeration (size=10)
138
+
139
+ ```
140
+ Warming up --------------------------------------
141
+ Hash.keys.each 201.546k i/100ms
142
+ Hash.each_key 209.461k i/100ms
143
+ Calculating -------------------------------------
144
+ Hash.keys.each 2.019M (± 0.3%) i/s - 10.279M in 5.092727s
145
+ Hash.each_key 2.095M (± 0.0%) i/s - 10.683M in 5.099576s
146
+ with 95.0% confidence
147
+
148
+ Comparison:
149
+ Hash.each_key: 2094785.3 i/s
150
+ Hash.keys.each: 2018768.6 i/s - 1.04x (± 0.00) slower
151
+ with 95.0% confidence
152
+ ```
153
+
154
+ #### Hash key enumeration (size=20)
155
+
156
+ ```
157
+ Warming up --------------------------------------
158
+ Hash.keys.each 118.004k i/100ms
159
+ Hash.each_key 118.320k i/100ms
160
+ Calculating -------------------------------------
161
+ Hash.keys.each 1.176M (± 0.4%) i/s - 5.900M in 5.021554s
162
+ Hash.each_key 1.182M (± 0.2%) i/s - 5.916M in 5.006809s
163
+ with 95.0% confidence
164
+
165
+ Comparison:
166
+ Hash.each_key: 1181738.4 i/s
167
+ Hash.keys.each: 1175522.6 i/s - same-ish: difference falls within error
168
+ with 95.0% confidence
169
+ ```
170
+
171
+ #### Hash key enumeration (size=100)
172
+
173
+ ```
174
+ Warming up --------------------------------------
175
+ Hash.keys.each 27.217k i/100ms
176
+ Hash.each_key 26.138k i/100ms
177
+ Calculating -------------------------------------
178
+ Hash.keys.each 272.497k (± 0.0%) i/s - 1.388M in 5.093882s
179
+ Hash.each_key 260.563k (± 0.4%) i/s - 1.307M in 5.017483s
180
+ with 95.0% confidence
181
+
182
+ Comparison:
183
+ Hash.keys.each: 272497.2 i/s
184
+ Hash.each_key: 260563.2 i/s - 1.05x (± 0.00) slower
185
+ with 95.0% confidence
186
+ ```
187
+
188
+ #### Hash key enumeration (size=500)
189
+
190
+ ```
191
+ Warming up --------------------------------------
192
+ Hash.keys.each 5.592k i/100ms
193
+ Hash.each_key 5.404k i/100ms
194
+ Calculating -------------------------------------
195
+ Hash.keys.each 55.763k (± 0.2%) i/s - 279.600k in 5.014897s
196
+ Hash.each_key 54.060k (± 0.1%) i/s - 275.604k in 5.098253s
197
+ with 95.0% confidence
198
+
199
+ Comparison:
200
+ Hash.keys.each: 55763.3 i/s
201
+ Hash.each_key: 54060.3 i/s - 1.03x (± 0.00) slower
202
+ with 95.0% confidence
203
+ ```
204
+
205
+ #### Hash value enumeration (size=0)
206
+
207
+ ```
208
+ Warming up --------------------------------------
209
+ Hash.values.each 922.361k i/100ms
210
+ Hash.each_value 1.372M i/100ms
211
+ Calculating -------------------------------------
212
+ Hash.values.each 9.229M (± 0.0%) i/s - 47.040M in 5.096857s
213
+ Hash.each_value 13.736M (± 0.0%) i/s - 69.983M in 5.094986s
214
+ with 95.0% confidence
215
+
216
+ Comparison:
217
+ Hash.each_value: 13735592.7 i/s
218
+ Hash.values.each: 9229287.5 i/s - 1.49x (± 0.00) slower
219
+ with 95.0% confidence
220
+ ```
221
+
222
+ #### Hash value enumeration (size=5)
223
+
224
+ ```
225
+ Warming up --------------------------------------
226
+ Hash.values.each 317.174k i/100ms
227
+ Hash.each_value 358.507k i/100ms
228
+ Calculating -------------------------------------
229
+ Hash.values.each 3.190M (± 0.0%) i/s - 16.176M in 5.071511s
230
+ Hash.each_value 3.582M (± 0.0%) i/s - 17.925M in 5.004607s
231
+ with 95.0% confidence
232
+
233
+ Comparison:
234
+ Hash.each_value: 3581759.4 i/s
235
+ Hash.values.each: 3189555.5 i/s - 1.12x (± 0.00) slower
236
+ with 95.0% confidence
237
+ ```
238
+
239
+ #### Hash value enumeration (size=10)
240
+
241
+ ```
242
+ Warming up --------------------------------------
243
+ Hash.values.each 201.766k i/100ms
244
+ Hash.each_value 209.128k i/100ms
245
+ Calculating -------------------------------------
246
+ Hash.values.each 2.032M (± 0.0%) i/s - 10.290M in 5.065224s
247
+ Hash.each_value 2.093M (± 0.0%) i/s - 10.666M in 5.096053s
248
+ with 95.0% confidence
249
+
250
+ Comparison:
251
+ Hash.each_value: 2092905.3 i/s
252
+ Hash.values.each: 2031517.4 i/s - 1.03x (± 0.00) slower
253
+ with 95.0% confidence
254
+ ```
255
+
256
+ #### Hash value enumeration (size=20)
257
+
258
+ ```
259
+ Warming up --------------------------------------
260
+ Hash.values.each 117.255k i/100ms
261
+ Hash.each_value 117.577k i/100ms
262
+ Calculating -------------------------------------
263
+ Hash.values.each 1.182M (± 0.1%) i/s - 5.980M in 5.058729s
264
+ Hash.each_value 1.176M (± 0.0%) i/s - 5.996M in 5.098809s
265
+ with 95.0% confidence
266
+
267
+ Comparison:
268
+ Hash.values.each: 1182126.7 i/s
269
+ Hash.each_value: 1176047.5 i/s - 1.01x (± 0.00) slower
270
+ with 95.0% confidence
271
+ ```
272
+
273
+ #### Hash value enumeration (size=100)
274
+
275
+ ```
276
+ Warming up --------------------------------------
277
+ Hash.values.each 27.263k i/100ms
278
+ Hash.each_value 26.208k i/100ms
279
+ Calculating -------------------------------------
280
+ Hash.values.each 275.209k (± 0.0%) i/s - 1.390M in 5.052242s
281
+ Hash.each_value 261.696k (± 0.0%) i/s - 1.310M in 5.007358s
282
+ with 95.0% confidence
283
+
284
+ Comparison:
285
+ Hash.values.each: 275209.0 i/s
286
+ Hash.each_value: 261696.2 i/s - 1.05x (± 0.00) slower
287
+ with 95.0% confidence
288
+ ```
289
+
290
+ #### Hash value enumeration (size=500)
291
+
292
+ ```
293
+ Warming up --------------------------------------
294
+ Hash.values.each 5.586k i/100ms
295
+ Hash.each_value 5.408k i/100ms
296
+ Calculating -------------------------------------
297
+ Hash.values.each 56.245k (± 0.2%) i/s - 284.886k in 5.066190s
298
+ Hash.each_value 54.104k (± 0.0%) i/s - 275.808k in 5.097780s
299
+ with 95.0% confidence
300
+
301
+ Comparison:
302
+ Hash.values.each: 56244.5 i/s
303
+ Hash.each_value: 54104.0 i/s - 1.04x (± 0.00) slower
304
+ with 95.0% confidence
305
+ ```
@@ -5,7 +5,7 @@ require_relative 'bm_setup'
5
5
 
6
6
  display_benchmark_header
7
7
 
8
- ENUM = (1..100)
8
+ ENUM = (1..100).freeze
9
9
 
10
10
  def hash_merge
11
11
  tmp = {}
@@ -0,0 +1,455 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Run from the command line: bundle exec ruby benchmarks/hash_merge.rb
4
+ require_relative 'bm_setup'
5
+
6
+ display_benchmark_header
7
+
8
+ # rubocop:disable Style/HashTransformKeys
9
+ # Bad per Rubocop
10
+ def hash_transform_key_each_with_object(hash)
11
+ hash.each_with_object({}) { |(k, v), h| h[k + 100] = v }
12
+ end
13
+
14
+ # Bad per Rubocop
15
+ def hash_transform_key_hash_collect(hash)
16
+ Hash[hash.collect { |k, v| [k + 100, v] }]
17
+ end
18
+
19
+ # Bad per Rubocop
20
+ def hash_transform_key_map_to_h(hash)
21
+ hash.map { |k, v| [k + 100, v] }.to_h
22
+ end
23
+
24
+ # Bad per Rubocop
25
+ def hash_transform_key_to_h_block(hash)
26
+ hash.to_h { |k, v| [k + 100, v] }
27
+ end
28
+
29
+ # Good per Rubocop
30
+ def hash_transform_keys(hash)
31
+ hash.transform_keys { |k| k + 100 }
32
+ end
33
+ # rubocop:enable Style/HashTransformKeys
34
+
35
+ [
36
+ [],
37
+ (1..5),
38
+ (1..10),
39
+ (1..20),
40
+ (1..100),
41
+ (1..500),
42
+ ].each do |data|
43
+ test_hash = data.zip(data).to_h
44
+
45
+ section "Hash transform keys (size=#{data.size})" do |bench|
46
+ bench.report("each_with_object") do
47
+ hash_transform_key_each_with_object(test_hash)
48
+ end
49
+
50
+ bench.report("collect.Hash") do
51
+ hash_transform_key_hash_collect(test_hash)
52
+ end
53
+
54
+ bench.report("map.to_h") do
55
+ hash_transform_key_map_to_h(test_hash)
56
+ end
57
+
58
+ bench.report("to_h block") do
59
+ hash_transform_key_to_h_block(test_hash)
60
+ end
61
+
62
+ bench.report("transform_keys") do
63
+ hash_transform_keys(test_hash)
64
+ end
65
+ end
66
+ end
67
+
68
+ # rubocop:disable Style/HashTransformValues
69
+ # Bad per Rubocop
70
+ def hash_transform_value_each_with_object(hash)
71
+ hash.each_with_object({}) { |(k, v), h| h[k] = v + 100 }
72
+ end
73
+
74
+ # Bad per Rubocop
75
+ def hash_transform_value_hash_collect(hash)
76
+ Hash[hash.collect { |k, v| [k, v + 100] }]
77
+ end
78
+
79
+ # Bad per Rubocop
80
+ def hash_transform_value_map_to_h(hash)
81
+ hash.map { |k, v| [k, v + 100] }.to_h
82
+ end
83
+
84
+ # Bad per Rubocop
85
+ def hash_transform_value_to_h_block(hash)
86
+ hash.to_h { |k, v| [k, v + 100] }
87
+ end
88
+
89
+ # Good per Rubocop
90
+ def hash_transform_values(hash)
91
+ hash.transform_values { |v| v + 100 }
92
+ end
93
+ # rubocop:enable Style/HashTransformValues
94
+
95
+ [
96
+ [],
97
+ (1..5),
98
+ (1..10),
99
+ (1..20),
100
+ (1..100),
101
+ (1..500),
102
+ ].each do |data|
103
+ test_hash = data.zip(data).to_h
104
+
105
+ section "Hash value enumeration (size=#{data.size})" do |bench|
106
+ bench.report("each_with_object") do
107
+ hash_transform_value_each_with_object(test_hash)
108
+ end
109
+
110
+ bench.report("collect.Hash") do
111
+ hash_transform_value_hash_collect(test_hash)
112
+ end
113
+
114
+ bench.report("map.to_h") do
115
+ hash_transform_value_map_to_h(test_hash)
116
+ end
117
+
118
+ bench.report("to_h block") do
119
+ hash_transform_value_to_h_block(test_hash)
120
+ end
121
+
122
+ bench.report("transform_values") do
123
+ hash_transform_values(test_hash)
124
+ end
125
+ end
126
+ end
127
+
128
+ __END__
129
+
130
+ ### Environment
131
+
132
+ Heroku Performance-L Dyno
133
+
134
+ ruby 2.7.3p183 (2021-04-05 revision 6847ee089d) [x86_64-linux]
135
+ GC Disabled: false
136
+
137
+ ### Test Cases
138
+
139
+ These benchmarks confirm that regardless of the size of the hash, the
140
+ `transform_xyz` variants are much faster than the alternatives. It's
141
+ interesting to note that the performance difference for some of the variants
142
+ decreases as the hash size increases. However, even with the largest hash the
143
+ `transform_xyz` version is significantly faster.
144
+
145
+ #### Hash transform keys (size=0)
146
+
147
+ ```
148
+ Warming up --------------------------------------
149
+ each_with_object 538.673k i/100ms
150
+ collect.Hash 342.897k i/100ms
151
+ map.to_h 426.927k i/100ms
152
+ to_h block 1.043M i/100ms
153
+ transform_keys 1.083M i/100ms
154
+ Calculating -------------------------------------
155
+ each_with_object 5.396M (± 0.0%) i/s - 27.472M in 5.091587s
156
+ collect.Hash 3.434M (± 0.0%) i/s - 17.488M in 5.093257s
157
+ map.to_h 4.263M (± 0.0%) i/s - 21.346M in 5.007195s
158
+ to_h block 10.431M (± 0.0%) i/s - 52.164M in 5.000982s
159
+ transform_keys 10.821M (± 0.0%) i/s - 54.133M in 5.002821s
160
+ with 95.0% confidence
161
+
162
+ Comparison:
163
+ transform_keys: 10820597.2 i/s
164
+ to_h block: 10430816.6 i/s - 1.04x (± 0.00) slower
165
+ each_with_object: 5395639.2 i/s - 2.01x (± 0.00) slower
166
+ map.to_h: 4263178.7 i/s - 2.54x (± 0.00) slower
167
+ collect.Hash: 3433510.5 i/s - 3.15x (± 0.00) slower
168
+ with 95.0% confidence
169
+ ```
170
+
171
+ #### Hash transform keys (size=5)
172
+
173
+ ```
174
+ Warming up --------------------------------------
175
+ each_with_object 101.033k i/100ms
176
+ collect.Hash 91.559k i/100ms
177
+ map.to_h 97.138k i/100ms
178
+ to_h block 144.964k i/100ms
179
+ transform_keys 236.915k i/100ms
180
+ Calculating -------------------------------------
181
+ each_with_object 1.009M (± 0.0%) i/s - 5.052M in 5.008941s
182
+ collect.Hash 914.359k (± 0.2%) i/s - 4.578M in 5.007666s
183
+ map.to_h 968.789k (± 0.0%) i/s - 4.857M in 5.013387s
184
+ to_h block 1.452M (± 0.0%) i/s - 7.393M in 5.091421s
185
+ transform_keys 2.371M (± 0.1%) i/s - 12.083M in 5.096820s
186
+ with 95.0% confidence
187
+
188
+ Comparison:
189
+ transform_keys: 2370806.9 i/s
190
+ to_h block: 1452082.9 i/s - 1.63x (± 0.00) slower
191
+ each_with_object: 1008530.1 i/s - 2.35x (± 0.00) slower
192
+ map.to_h: 968788.7 i/s - 2.45x (± 0.00) slower
193
+ collect.Hash: 914358.6 i/s - 2.59x (± 0.01) slower
194
+ with 95.0% confidence
195
+ ```
196
+
197
+ #### Hash transform keys (size=10)
198
+
199
+ ```
200
+ Warming up --------------------------------------
201
+ each_with_object 48.415k i/100ms
202
+ collect.Hash 49.273k i/100ms
203
+ map.to_h 54.155k i/100ms
204
+ to_h block 72.567k i/100ms
205
+ transform_keys 99.649k i/100ms
206
+ Calculating -------------------------------------
207
+ each_with_object 438.801k (± 0.2%) i/s - 2.227M in 5.075718s
208
+ collect.Hash 493.563k (± 0.1%) i/s - 2.513M in 5.091711s
209
+ map.to_h 550.742k (± 0.0%) i/s - 2.762M in 5.014922s
210
+ to_h block 725.526k (± 0.0%) i/s - 3.628M in 5.001047s
211
+ transform_keys 997.743k (± 0.4%) i/s - 5.082M in 5.094699s
212
+ with 95.0% confidence
213
+
214
+ Comparison:
215
+ transform_keys: 997742.9 i/s
216
+ to_h block: 725525.6 i/s - 1.38x (± 0.00) slower
217
+ map.to_h: 550741.9 i/s - 1.81x (± 0.01) slower
218
+ collect.Hash: 493562.5 i/s - 2.02x (± 0.01) slower
219
+ each_with_object: 438801.5 i/s - 2.27x (± 0.01) slower
220
+ with 95.0% confidence
221
+ ```
222
+
223
+ #### Hash transform keys (size=20)
224
+
225
+ ```
226
+ Warming up --------------------------------------
227
+ each_with_object 27.891k i/100ms
228
+ collect.Hash 30.118k i/100ms
229
+ map.to_h 31.586k i/100ms
230
+ to_h block 41.472k i/100ms
231
+ transform_keys 56.874k i/100ms
232
+ Calculating -------------------------------------
233
+ each_with_object 259.309k (± 0.2%) i/s - 1.311M in 5.055247s
234
+ collect.Hash 301.677k (± 0.0%) i/s - 1.536M in 5.091598s
235
+ map.to_h 316.764k (± 0.0%) i/s - 1.611M in 5.085459s
236
+ to_h block 416.878k (± 0.0%) i/s - 2.115M in 5.073771s
237
+ transform_keys 566.454k (± 0.4%) i/s - 2.844M in 5.021314s
238
+ with 95.0% confidence
239
+
240
+ Comparison:
241
+ transform_keys: 566453.6 i/s
242
+ to_h block: 416877.9 i/s - 1.36x (± 0.01) slower
243
+ map.to_h: 316763.9 i/s - 1.79x (± 0.01) slower
244
+ collect.Hash: 301677.3 i/s - 1.88x (± 0.01) slower
245
+ each_with_object: 259308.7 i/s - 2.18x (± 0.01) slower
246
+ with 95.0% confidence
247
+ ```
248
+
249
+ #### Hash transform keys (size=100)
250
+
251
+ ```
252
+ Warming up --------------------------------------
253
+ each_with_object 6.252k i/100ms
254
+ collect.Hash 6.684k i/100ms
255
+ map.to_h 7.193k i/100ms
256
+ to_h block 9.181k i/100ms
257
+ transform_keys 12.110k i/100ms
258
+ Calculating -------------------------------------
259
+ each_with_object 62.523k (± 0.0%) i/s - 318.852k in 5.099821s
260
+ collect.Hash 66.729k (± 0.0%) i/s - 334.200k in 5.008308s
261
+ map.to_h 71.711k (± 0.0%) i/s - 359.650k in 5.015342s
262
+ to_h block 91.347k (± 0.0%) i/s - 459.050k in 5.025450s
263
+ transform_keys 122.210k (± 0.1%) i/s - 617.610k in 5.053842s
264
+ with 95.0% confidence
265
+
266
+ Comparison:
267
+ transform_keys: 122210.0 i/s
268
+ to_h block: 91347.2 i/s - 1.34x (± 0.00) slower
269
+ map.to_h: 71710.5 i/s - 1.70x (± 0.00) slower
270
+ collect.Hash: 66729.5 i/s - 1.83x (± 0.00) slower
271
+ each_with_object: 62522.6 i/s - 1.95x (± 0.00) slower
272
+ with 95.0% confidence
273
+ ```
274
+
275
+ #### Hash transform keys (size=500)
276
+
277
+ ```
278
+ Warming up --------------------------------------
279
+ each_with_object 1.309k i/100ms
280
+ collect.Hash 1.397k i/100ms
281
+ map.to_h 1.501k i/100ms
282
+ to_h block 1.881k i/100ms
283
+ transform_keys 2.564k i/100ms
284
+ Calculating -------------------------------------
285
+ each_with_object 13.113k (± 0.1%) i/s - 66.759k in 5.090832s
286
+ collect.Hash 13.971k (± 0.1%) i/s - 69.850k in 5.000147s
287
+ map.to_h 14.983k (± 0.0%) i/s - 75.050k in 5.009121s
288
+ to_h block 18.827k (± 0.0%) i/s - 95.931k in 5.095314s
289
+ transform_keys 26.712k (± 0.8%) i/s - 135.892k in 5.092990s
290
+ with 95.0% confidence
291
+
292
+ Comparison:
293
+ transform_keys: 26711.7 i/s
294
+ to_h block: 18827.4 i/s - 1.42x (± 0.01) slower
295
+ map.to_h: 14982.9 i/s - 1.78x (± 0.01) slower
296
+ collect.Hash: 13970.7 i/s - 1.91x (± 0.02) slower
297
+ each_with_object: 13113.5 i/s - 2.04x (± 0.02) slower
298
+ with 95.0% confidence
299
+ ```
300
+
301
+ #### Hash value enumeration (size=0)
302
+
303
+ ```
304
+ Warming up --------------------------------------
305
+ each_with_object 536.283k i/100ms
306
+ collect.Hash 343.935k i/100ms
307
+ map.to_h 412.861k i/100ms
308
+ to_h block 1.006M i/100ms
309
+ transform_values 1.034M i/100ms
310
+ Calculating -------------------------------------
311
+ each_with_object 5.354M (± 0.3%) i/s - 26.814M in 5.009608s
312
+ collect.Hash 3.438M (± 0.0%) i/s - 17.197M in 5.001856s
313
+ map.to_h 4.129M (± 0.0%) i/s - 20.643M in 4.999982s
314
+ to_h block 9.850M (± 0.0%) i/s - 49.315M in 5.006595s
315
+ transform_values 10.253M (± 0.0%) i/s - 51.721M in 5.044573s
316
+ with 95.0% confidence
317
+
318
+ Comparison:
319
+ transform_values: 10252746.8 i/s
320
+ to_h block: 9850031.5 i/s - 1.04x (± 0.00) slower
321
+ each_with_object: 5353850.7 i/s - 1.92x (± 0.01) slower
322
+ map.to_h: 4128725.3 i/s - 2.48x (± 0.00) slower
323
+ collect.Hash: 3438102.9 i/s - 2.98x (± 0.00) slower
324
+ with 95.0% confidence
325
+ ```
326
+
327
+ #### Hash value enumeration (size=5)
328
+
329
+ ```
330
+ Warming up --------------------------------------
331
+ each_with_object 101.174k i/100ms
332
+ collect.Hash 91.846k i/100ms
333
+ map.to_h 96.742k i/100ms
334
+ to_h block 144.714k i/100ms
335
+ transform_values 334.829k i/100ms
336
+ Calculating -------------------------------------
337
+ each_with_object 1.011M (± 0.0%) i/s - 5.059M in 5.002511s
338
+ collect.Hash 916.962k (± 0.0%) i/s - 4.592M in 5.008221s
339
+ map.to_h 969.007k (± 0.0%) i/s - 4.934M in 5.091657s
340
+ to_h block 1.447M (± 0.0%) i/s - 7.236M in 5.000091s
341
+ transform_values 3.356M (± 0.1%) i/s - 17.076M in 5.089207s
342
+ with 95.0% confidence
343
+
344
+ Comparison:
345
+ transform_values: 3355662.6 i/s
346
+ to_h block: 1447114.5 i/s - 2.32x (± 0.00) slower
347
+ each_with_object: 1011242.1 i/s - 3.32x (± 0.00) slower
348
+ map.to_h: 969007.2 i/s - 3.46x (± 0.00) slower
349
+ collect.Hash: 916962.3 i/s - 3.66x (± 0.00) slower
350
+ with 95.0% confidence
351
+ ```
352
+
353
+ #### Hash value enumeration (size=10)
354
+
355
+ ```
356
+ Warming up --------------------------------------
357
+ each_with_object 48.473k i/100ms
358
+ collect.Hash 49.061k i/100ms
359
+ map.to_h 53.340k i/100ms
360
+ to_h block 72.241k i/100ms
361
+ transform_values 146.939k i/100ms
362
+ Calculating -------------------------------------
363
+ each_with_object 480.559k (± 0.1%) i/s - 2.424M in 5.043419s
364
+ collect.Hash 492.989k (± 0.0%) i/s - 2.502M in 5.075419s
365
+ map.to_h 546.714k (± 0.0%) i/s - 2.774M in 5.073369s
366
+ to_h block 725.482k (± 0.0%) i/s - 3.684M in 5.078410s
367
+ transform_values 1.575M (± 0.2%) i/s - 7.935M in 5.036956s
368
+ with 95.0% confidence
369
+
370
+ Comparison:
371
+ transform_values: 1575397.1 i/s
372
+ to_h block: 725482.0 i/s - 2.17x (± 0.00) slower
373
+ map.to_h: 546714.4 i/s - 2.88x (± 0.00) slower
374
+ collect.Hash: 492988.8 i/s - 3.20x (± 0.01) slower
375
+ each_with_object: 480559.2 i/s - 3.28x (± 0.01) slower
376
+ with 95.0% confidence
377
+ ```
378
+
379
+ #### Hash value enumeration (size=20)
380
+
381
+ ```
382
+ Warming up --------------------------------------
383
+ each_with_object 28.320k i/100ms
384
+ collect.Hash 30.250k i/100ms
385
+ map.to_h 31.925k i/100ms
386
+ to_h block 42.127k i/100ms
387
+ transform_values 87.393k i/100ms
388
+ Calculating -------------------------------------
389
+ each_with_object 269.839k (± 0.2%) i/s - 1.359M in 5.037950s
390
+ collect.Hash 303.464k (± 0.2%) i/s - 1.543M in 5.084567s
391
+ map.to_h 318.494k (± 0.0%) i/s - 1.596M in 5.011840s
392
+ to_h block 419.913k (± 0.0%) i/s - 2.106M in 5.016300s
393
+ transform_values 801.802k (± 0.6%) i/s - 4.020M in 5.015563s
394
+ with 95.0% confidence
395
+
396
+ Comparison:
397
+ transform_values: 801801.6 i/s
398
+ to_h block: 419913.0 i/s - 1.91x (± 0.01) slower
399
+ map.to_h: 318494.2 i/s - 2.52x (± 0.01) slower
400
+ collect.Hash: 303464.4 i/s - 2.64x (± 0.02) slower
401
+ each_with_object: 269839.2 i/s - 2.97x (± 0.02) slower
402
+ with 95.0% confidence
403
+ ```
404
+
405
+ #### Hash value enumeration (size=100)
406
+
407
+ ```
408
+ Warming up --------------------------------------
409
+ each_with_object 6.319k i/100ms
410
+ collect.Hash 6.686k i/100ms
411
+ map.to_h 7.245k i/100ms
412
+ to_h block 9.317k i/100ms
413
+ transform_values 20.555k i/100ms
414
+ Calculating -------------------------------------
415
+ each_with_object 63.102k (± 0.3%) i/s - 315.950k in 5.008225s
416
+ collect.Hash 66.782k (± 0.0%) i/s - 334.300k in 5.005839s
417
+ map.to_h 72.403k (± 0.0%) i/s - 362.250k in 5.003248s
418
+ to_h block 93.020k (± 0.0%) i/s - 465.850k in 5.008075s
419
+ transform_values 207.295k (± 0.1%) i/s - 1.048M in 5.057171s
420
+ with 95.0% confidence
421
+
422
+ Comparison:
423
+ transform_values: 207294.9 i/s
424
+ to_h block: 93020.0 i/s - 2.23x (± 0.00) slower
425
+ map.to_h: 72403.1 i/s - 2.86x (± 0.00) slower
426
+ collect.Hash: 66782.1 i/s - 3.10x (± 0.00) slower
427
+ each_with_object: 63102.3 i/s - 3.28x (± 0.01) slower
428
+ with 95.0% confidence
429
+ ```
430
+
431
+ #### Hash value enumeration (size=500)
432
+
433
+ ```
434
+ Warming up --------------------------------------
435
+ each_with_object 1.316k i/100ms
436
+ collect.Hash 1.398k i/100ms
437
+ map.to_h 1.496k i/100ms
438
+ to_h block 1.876k i/100ms
439
+ transform_values 4.471k i/100ms
440
+ Calculating -------------------------------------
441
+ each_with_object 13.154k (± 0.1%) i/s - 65.800k in 5.002444s
442
+ collect.Hash 13.983k (± 0.0%) i/s - 71.298k in 5.099149s
443
+ map.to_h 14.968k (± 0.0%) i/s - 76.296k in 5.097225s
444
+ to_h block 18.745k (± 0.0%) i/s - 93.800k in 5.004043s
445
+ transform_values 44.903k (± 0.7%) i/s - 228.021k in 5.082046s
446
+ with 95.0% confidence
447
+
448
+ Comparison:
449
+ transform_values: 44903.5 i/s
450
+ to_h block: 18744.9 i/s - 2.40x (± 0.02) slower
451
+ map.to_h: 14968.1 i/s - 3.00x (± 0.02) slower
452
+ collect.Hash: 13982.6 i/s - 3.21x (± 0.02) slower
453
+ each_with_object: 13153.9 i/s - 3.41x (± 0.02) slower
454
+ with 95.0% confidence
455
+ ```