radius-spec 0.2.0 → 0.6.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.
@@ -0,0 +1,70 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'kalibera'
4
+ require 'benchmark/ips'
5
+
6
+ # Enable and start GC before each job run. Disable GC afterwards.
7
+ #
8
+ # Inspired by https://www.omniref.com/ruby/2.2.1/symbols/Benchmark/bm?#annotation=4095926&line=182
9
+ class GCSuite
10
+ def warming(*)
11
+ run_gc
12
+ end
13
+
14
+ def running(*)
15
+ run_gc
16
+ end
17
+
18
+ def warmup_stats(*)
19
+ end
20
+
21
+ def add_report(*)
22
+ end
23
+
24
+ private
25
+
26
+ def run_gc
27
+ GC.enable
28
+ GC.start
29
+ GC.disable
30
+ end
31
+ end
32
+
33
+ def as_boolean(val, default: nil)
34
+ case val.to_s.strip.downcase
35
+ when "true", "t", "yes", "y", "on", "1"
36
+ true
37
+ when "false", "f", "no", "n", "off", "0"
38
+ false
39
+ else
40
+ raise "Unknown boolean value #{val}" if default.nil?
41
+
42
+ default
43
+ end
44
+ end
45
+
46
+ def section(title = nil)
47
+ puts "\n#### #{title}" if title
48
+ puts "\n```"
49
+ GC.start
50
+ Benchmark.ips do |bench|
51
+ bench.config suite: GCSuite.new if GC_DISABLED
52
+ bench.config stats: :bootstrap, confidence: 95
53
+
54
+ yield bench
55
+ bench.compare!
56
+ end
57
+ puts "```"
58
+ end
59
+
60
+ def display_benchmark_header
61
+ puts
62
+ puts "### Environment"
63
+ puts
64
+ puts RUBY_DESCRIPTION
65
+ puts "GC Disabled: #{GC_DISABLED}"
66
+ puts
67
+ puts "### Test Cases"
68
+ end
69
+
70
+ GC_DISABLED = as_boolean(ENV['GC_DISABLED'], default: false)
@@ -0,0 +1,181 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Run from the command line: bundle exec ruby benchmarks/call_vs_yield.rb
4
+ require_relative 'bm_setup'
5
+
6
+ display_benchmark_header
7
+
8
+ # rubocop:disable Performance/RedundantBlockCall
9
+ def block_call(&block)
10
+ block.call
11
+ end
12
+
13
+ def block_yield(&_block)
14
+ yield
15
+ end
16
+
17
+ def block_arg(&_block)
18
+ 1 + 1 # Always do the same amount of work
19
+ end
20
+
21
+ def no_arg_yield
22
+ yield
23
+ end
24
+
25
+ def pass_through(&block)
26
+ no_arg_yield(&block)
27
+ end
28
+
29
+ section "Block call vs yield" do |bench|
30
+ bench.report("block.call") do |times|
31
+ i = 0
32
+ while i < times
33
+ block_call do
34
+ 1 + 1
35
+ end
36
+ i += 1
37
+ end
38
+ end
39
+
40
+ bench.report("block yield") do |times|
41
+ i = 0
42
+ while i < times
43
+ block_yield do
44
+ 1 + 1
45
+ end
46
+ i += 1
47
+ end
48
+ end
49
+
50
+ bench.report("block arg only") do |times|
51
+ i = 0
52
+ while i < times
53
+ block_arg do
54
+ 1 + 1
55
+ end
56
+ i += 1
57
+ end
58
+ end
59
+
60
+ bench.report("no arg yield") do |times|
61
+ i = 0
62
+ while i < times
63
+ no_arg_yield do
64
+ 1 + 1
65
+ end
66
+ i += 1
67
+ end
68
+ end
69
+
70
+ bench.report("pass through block") do |times|
71
+ i = 0
72
+ while i < times
73
+ pass_through do
74
+ 1 + 1
75
+ end
76
+ i += 1
77
+ end
78
+ end
79
+ end
80
+ # rubocop:enable Performance/RedundantBlockCall
81
+
82
+ __END__
83
+
84
+ ### Environment
85
+
86
+ ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-darwin16]
87
+ GC Disabled: false
88
+
89
+ ### Test Cases
90
+
91
+ #### Block call vs yield
92
+
93
+ ```
94
+ Warming up --------------------------------------
95
+ block.call 117.672k i/100ms
96
+ block yield 272.613k i/100ms
97
+ block arg only 287.821k i/100ms
98
+ no arg yield 286.217k i/100ms
99
+ pass through block 251.757k i/100ms
100
+ Calculating -------------------------------------
101
+ block.call 3.181M (± 0.9%) i/s - 15.886M in 5.010444s
102
+ block yield 14.017M (± 0.7%) i/s - 70.062M in 5.015163s
103
+ block arg only 17.835M (± 0.7%) i/s - 88.937M in 5.011243s
104
+ no arg yield 18.056M (± 0.6%) i/s - 90.158M in 5.010075s
105
+ pass through block 10.776M (± 0.8%) i/s - 53.876M in 5.019221s
106
+ with 95.0% confidence
107
+
108
+ Comparison:
109
+ no arg yield: 18056296.4 i/s
110
+ block arg only: 17835047.6 i/s - same-ish: difference falls within error
111
+ block yield: 14017426.6 i/s - 1.29x (± 0.01) slower
112
+ pass through block: 10776151.4 i/s - 1.68x (± 0.02) slower
113
+ block.call: 3180610.0 i/s - 5.68x (± 0.06) slower
114
+ with 95.0% confidence
115
+ ```
116
+
117
+ ### Environment
118
+
119
+ ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-darwin16]
120
+ GC Disabled: true
121
+
122
+ ### Test Cases
123
+
124
+ #### Block call vs yield
125
+
126
+ ```
127
+ Warming up --------------------------------------
128
+ block.call 134.623k i/100ms
129
+ block yield 276.955k i/100ms
130
+ block arg only 306.377k i/100ms
131
+ no arg yield 286.201k i/100ms
132
+ pass through block 259.025k i/100ms
133
+ Calculating -------------------------------------
134
+ block.call 3.558M (± 2.6%) i/s - 17.097M in 5.033155s
135
+ block yield 14.469M (± 0.7%) i/s - 72.285M in 5.013029s
136
+ block arg only 18.173M (± 0.6%) i/s - 90.688M in 5.005679s
137
+ no arg yield 18.207M (± 0.6%) i/s - 90.726M in 5.001766s
138
+ pass through block 10.794M (± 0.8%) i/s - 53.877M in 5.010781s
139
+ with 95.0% confidence
140
+
141
+ Comparison:
142
+ no arg yield: 18206595.2 i/s
143
+ block arg only: 18172764.0 i/s - same-ish: difference falls within error
144
+ block yield: 14469142.9 i/s - 1.26x (± 0.01) slower
145
+ pass through block: 10793657.6 i/s - 1.69x (± 0.02) slower
146
+ block.call: 3557929.5 i/s - 5.12x (± 0.14) slower
147
+ with 95.0% confidence
148
+ ```
149
+
150
+ ### Environment
151
+
152
+ ruby 2.6.0p0 (2018-12-25 revision 66547) [x86_64-darwin16]
153
+ GC Disabled: false
154
+
155
+ ### Test Cases
156
+
157
+ #### Block call vs yield
158
+
159
+ ```
160
+ Warming up --------------------------------------
161
+ block.call 252.830k i/100ms
162
+ block yield 266.647k i/100ms
163
+ block arg only 275.856k i/100ms
164
+ no arg yield 271.677k i/100ms
165
+ pass through block 251.117k i/100ms
166
+ Calculating -------------------------------------
167
+ block.call 11.729M (± 0.9%) i/s - 58.404M in 5.004905s
168
+ block yield 13.216M (± 0.8%) i/s - 65.862M in 5.007922s
169
+ block arg only 17.288M (± 0.9%) i/s - 86.067M in 5.009110s
170
+ no arg yield 16.109M (± 0.9%) i/s - 80.145M in 5.006225s
171
+ pass through block 10.175M (± 1.0%) i/s - 50.726M in 5.010616s
172
+ with 95.0% confidence
173
+
174
+ Comparison:
175
+ block arg only: 17287836.2 i/s
176
+ no arg yield: 16108506.9 i/s - 1.07x (± 0.01) slower
177
+ block yield: 13215609.2 i/s - 1.31x (± 0.02) slower
178
+ block.call: 11729199.4 i/s - 1.47x (± 0.02) slower
179
+ pass through block: 10174648.1 i/s - 1.70x (± 0.02) slower
180
+ with 95.0% confidence
181
+ ```
@@ -0,0 +1,73 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Run from the command line: bundle exec ruby benchmarks/case_equality_vs_class_check.rb
4
+ require_relative 'bm_setup'
5
+
6
+ display_benchmark_header
7
+
8
+ section "Class match" do |bench|
9
+ x = "Any String"
10
+
11
+ bench.report("===") do
12
+ String === x # rubocop:disable Style/CaseEquality
13
+ end
14
+
15
+ bench.report("is_a?") do
16
+ x.is_a?(String)
17
+ end
18
+ end
19
+
20
+ section "Class NO match" do |bench|
21
+ x = :any_symbol
22
+
23
+ bench.report("===") do
24
+ String === x # rubocop:disable Style/CaseEquality
25
+ end
26
+
27
+ bench.report("is_a?") do
28
+ x.is_a?(String)
29
+ end
30
+ end
31
+
32
+ __END__
33
+
34
+ ### Environment
35
+
36
+ ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-darwin16]
37
+ GC Disabled: true
38
+
39
+ ### Test Cases
40
+
41
+ #### Class match
42
+
43
+ ```
44
+ Warming up --------------------------------------
45
+ === 284.703k i/100ms
46
+ is_a? 280.367k i/100ms
47
+ Calculating -------------------------------------
48
+ === 11.394M (± 0.8%) i/s - 56.941M in 5.014392s
49
+ is_a? 11.068M (± 0.8%) i/s - 55.232M in 5.007549s
50
+ with 95.0% confidence
51
+
52
+ Comparison:
53
+ ===: 11394313.8 i/s
54
+ is_a?: 11068062.4 i/s - 1.03x (± 0.01) slower
55
+ with 95.0% confidence
56
+ ```
57
+
58
+ #### Class NO match
59
+
60
+ ```
61
+ Warming up --------------------------------------
62
+ === 298.288k i/100ms
63
+ is_a? 290.294k i/100ms
64
+ Calculating -------------------------------------
65
+ === 10.567M (± 0.7%) i/s - 52.797M in 5.007023s
66
+ is_a? 10.405M (± 0.7%) i/s - 51.963M in 5.006983s
67
+ with 95.0% confidence
68
+
69
+ Comparison:
70
+ ===: 10567130.4 i/s
71
+ is_a?: 10405382.6 i/s - 1.02x (± 0.01) slower
72
+ with 95.0% confidence
73
+ ```
@@ -0,0 +1,488 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Run from the command line: bundle exec ruby benchmarks/casecmp_vs_downcase.rb
4
+ require_relative 'bm_setup'
5
+
6
+ display_benchmark_header
7
+
8
+ EXPECTED = "match"
9
+
10
+ puts "### Base Cases"
11
+
12
+ def downcase_eql(test_case)
13
+ EXPECTED == test_case.downcase
14
+ end
15
+
16
+ def casecmp_eql(test_case)
17
+ 0 == EXPECTED.casecmp(test_case)
18
+ end
19
+
20
+ def casecmp_zero(test_case)
21
+ EXPECTED.casecmp(test_case).zero?
22
+ end
23
+
24
+ # This is similar to the original Rubocop cited benchmark code.
25
+ ["No MaTcH", "MaTcH"].each do |test_case|
26
+ section "Case: #{test_case.downcase}" do |bench|
27
+ bench.report("== downcase") do
28
+ downcase_eql(test_case)
29
+ end
30
+
31
+ bench.report("== casecmp") do
32
+ casecmp_eql(test_case)
33
+ end
34
+
35
+ bench.report("casecmp.zero?") do
36
+ casecmp_zero(test_case)
37
+ end
38
+ end
39
+ end
40
+
41
+ # As of Ruby 2.5 both `casecmp` and `casecmp?` accept any object. In the cases
42
+ # where the object is not a string they return `nil`. Prior Ruby 2.5 string
43
+ # conversions need to occur before the compare.
44
+ puts "### Type Cases"
45
+
46
+ def tos_downcase_eql(test_case)
47
+ EXPECTED == test_case.to_s.downcase
48
+ end
49
+
50
+ def safe_casecmp_zero(test_case)
51
+ EXPECTED.casecmp(test_case)&.zero?
52
+ end
53
+
54
+ def casecmp_to_i_zero(test_case)
55
+ EXPECTED.casecmp(test_case).to_i.zero?
56
+ end
57
+
58
+ def casecmp?(test_case)
59
+ EXPECTED.casecmp?(test_case)
60
+ end
61
+
62
+ class StringLike
63
+ def initialize(test_case)
64
+ @test_case = test_case
65
+ end
66
+
67
+ def to_str
68
+ @test_case
69
+ end
70
+ end
71
+
72
+ [
73
+ nil,
74
+ "no match",
75
+ "match",
76
+ 123,
77
+ Object.new,
78
+ StringLike.new("no match"),
79
+ StringLike.new("match"),
80
+ ].each do |test_case|
81
+ section "Type Case: #{test_case.inspect}" do |bench|
82
+ bench.report("== to_s.downcase") do
83
+ tos_downcase_eql(test_case)
84
+ end
85
+
86
+ bench.report("== casecmp") do
87
+ casecmp_eql(test_case)
88
+ end
89
+
90
+ bench.report("casecmp.zero?") do
91
+ safe_casecmp_zero(test_case)
92
+ end
93
+
94
+ bench.report("casecmp.to_i.zero?") do
95
+ casecmp_to_i_zero(test_case)
96
+ end
97
+
98
+ bench.report("casecmp?") do
99
+ casecmp?(test_case)
100
+ end
101
+ end
102
+ end
103
+
104
+ def pre_casecmp_eql(test_case)
105
+ test_case && 0 == EXPECTED.casecmp(test_case)
106
+ end
107
+
108
+ def pre_casecmp_zero(test_case)
109
+ test_case && EXPECTED.casecmp(test_case).zero?
110
+ end
111
+
112
+ def pre_bang_casecmp_eql(test_case)
113
+ !!test_case && 0 == EXPECTED.casecmp(test_case)
114
+ end
115
+
116
+ def pre_bang_casecmp_zero(test_case)
117
+ !!test_case && EXPECTED.casecmp(test_case).zero?
118
+ end
119
+
120
+ def pre_nil_casecmp_eql(test_case)
121
+ !test_case.nil? && 0 == EXPECTED.casecmp(test_case)
122
+ end
123
+
124
+ def pre_nil_casecmp_zero(test_case)
125
+ !test_case.nil? && EXPECTED.casecmp(test_case).zero?
126
+ end
127
+
128
+ # Given the results below this is another set of tests to try to determine if
129
+ # knowing you'll either have `nil` or a `String`
130
+ [nil, "no match"].each do |test_case|
131
+ section "Pre-check Case: #{test_case.inspect}" do |bench|
132
+ bench.report("== casecmp(to_s)") do
133
+ casecmp_eql(test_case.to_s)
134
+ end
135
+
136
+ if RUBY_VERSION.to_f > 2.3
137
+ bench.report("casecmp?(to_s)") do
138
+ casecmp?(test_case.to_s)
139
+ end
140
+ end
141
+
142
+ if RUBY_VERSION.to_f > 2.4
143
+ bench.report("casecmp?") do
144
+ casecmp?(test_case)
145
+ end
146
+ end
147
+
148
+ bench.report("falsey casecmp.zero?") do
149
+ pre_casecmp_zero(test_case)
150
+ end
151
+
152
+ bench.report("falsey == casecmp") do
153
+ pre_casecmp_eql(test_case)
154
+ end
155
+
156
+ bench.report("!! casecmp.zero?") do
157
+ pre_bang_casecmp_zero(test_case)
158
+ end
159
+
160
+ bench.report("!! == casecmp") do
161
+ pre_bang_casecmp_eql(test_case)
162
+ end
163
+
164
+ bench.report("nil? casecmp.zero?") do
165
+ pre_nil_casecmp_zero(test_case)
166
+ end
167
+
168
+ bench.report("nil? == casecmp") do
169
+ pre_nil_casecmp_eql(test_case)
170
+ end
171
+ end
172
+ end
173
+
174
+ __END__
175
+
176
+ These results were a little surprising. With `casecmp?` being implemented in C
177
+ I fully expected that to be the fastest version. As the results below show, it
178
+ was actually the slowest except for the `nil` case. Given both `casecmp` and
179
+ `casecmp?` need to perform the same type coercions in Ruby 2.5 this is still
180
+ a bit of a mystery to me.
181
+
182
+ ### Environment
183
+
184
+ ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-darwin16]
185
+ GC Disabled: false
186
+
187
+ ### Test Cases
188
+
189
+ ### Base Cases
190
+
191
+ #### Case: no match
192
+
193
+ ```
194
+ Warming up --------------------------------------
195
+ == downcase 212.956k i/100ms
196
+ == casecmp 242.441k i/100ms
197
+ casecmp.zero? 250.362k i/100ms
198
+ Calculating -------------------------------------
199
+ == downcase 5.758M (± 1.1%) i/s - 28.749M in 5.013717s
200
+ == casecmp 7.263M (± 0.8%) i/s - 36.366M in 5.018952s
201
+ casecmp.zero? 6.641M (± 0.9%) i/s - 33.298M in 5.026902s
202
+ with 95.0% confidence
203
+
204
+ Comparison:
205
+ == casecmp: 7262964.1 i/s
206
+ casecmp.zero?: 6640838.5 i/s - 1.09x (± 0.01) slower
207
+ == downcase: 5757879.1 i/s - 1.26x (± 0.02) slower
208
+ with 95.0% confidence
209
+ ```
210
+
211
+ #### Case: match
212
+
213
+ ```
214
+ Warming up --------------------------------------
215
+ == downcase 223.277k i/100ms
216
+ == casecmp 255.309k i/100ms
217
+ casecmp.zero? 244.326k i/100ms
218
+ Calculating -------------------------------------
219
+ == downcase 5.601M (± 0.7%) i/s - 28.133M in 5.031201s
220
+ == casecmp 7.069M (± 0.9%) i/s - 35.488M in 5.033449s
221
+ casecmp.zero? 6.514M (± 1.0%) i/s - 32.495M in 5.007338s
222
+ with 95.0% confidence
223
+
224
+ Comparison:
225
+ == casecmp: 7069433.4 i/s
226
+ casecmp.zero?: 6513865.5 i/s - 1.09x (± 0.01) slower
227
+ == downcase: 5600607.7 i/s - 1.26x (± 0.01) slower
228
+ with 95.0% confidence
229
+ ```
230
+ ### Type Cases
231
+
232
+ #### Type Case: nil
233
+
234
+ ```
235
+ Warming up --------------------------------------
236
+ == to_s.downcase 206.757k i/100ms
237
+ == casecmp 165.652k i/100ms
238
+ casecmp.zero? 243.968k i/100ms
239
+ casecmp.to_i.zero? 228.771k i/100ms
240
+ casecmp? 245.631k i/100ms
241
+ Calculating -------------------------------------
242
+ == to_s.downcase 4.457M (± 1.3%) i/s - 22.330M in 5.036046s
243
+ == casecmp 2.959M (± 0.9%) i/s - 14.909M in 5.048155s
244
+ casecmp.zero? 6.571M (± 0.8%) i/s - 32.936M in 5.023643s
245
+ casecmp.to_i.zero? 5.610M (± 1.0%) i/s - 28.139M in 5.030920s
246
+ casecmp? 6.426M (± 0.9%) i/s - 32.178M in 5.022549s
247
+ with 95.0% confidence
248
+
249
+ Comparison:
250
+ casecmp.zero?: 6570981.1 i/s
251
+ casecmp?: 6426432.5 i/s - 1.02x (± 0.01) slower
252
+ casecmp.to_i.zero?: 5609983.7 i/s - 1.17x (± 0.02) slower
253
+ == to_s.downcase: 4457210.7 i/s - 1.47x (± 0.02) slower
254
+ == casecmp: 2959310.9 i/s - 2.22x (± 0.03) slower
255
+ with 95.0% confidence
256
+ ```
257
+
258
+ #### Type Case: "no match"
259
+
260
+ ```
261
+ Warming up --------------------------------------
262
+ == to_s.downcase 224.166k i/100ms
263
+ == casecmp 255.225k i/100ms
264
+ casecmp.zero? 244.858k i/100ms
265
+ casecmp.to_i.zero? 239.323k i/100ms
266
+ casecmp? 184.603k i/100ms
267
+ Calculating -------------------------------------
268
+ == to_s.downcase 4.986M (± 1.7%) i/s - 24.882M in 5.041514s
269
+ == casecmp 7.478M (± 0.9%) i/s - 37.518M in 5.033271s
270
+ casecmp.zero? 6.879M (± 1.0%) i/s - 34.525M in 5.036217s
271
+ casecmp.to_i.zero? 6.166M (± 0.9%) i/s - 30.873M in 5.021792s
272
+ casecmp? 4.520M (± 1.5%) i/s - 22.522M in 5.022920s
273
+ with 95.0% confidence
274
+
275
+ Comparison:
276
+ == casecmp: 7478045.4 i/s
277
+ casecmp.zero?: 6878660.6 i/s - 1.09x (± 0.01) slower
278
+ casecmp.to_i.zero?: 6166061.6 i/s - 1.21x (± 0.02) slower
279
+ == to_s.downcase: 4985671.0 i/s - 1.50x (± 0.03) slower
280
+ casecmp?: 4520190.0 i/s - 1.65x (± 0.03) slower
281
+ with 95.0% confidence
282
+ ```
283
+
284
+ #### Type Case: "match"
285
+
286
+ ```
287
+ Warming up --------------------------------------
288
+ == to_s.downcase 222.165k i/100ms
289
+ == casecmp 255.637k i/100ms
290
+ casecmp.zero? 242.725k i/100ms
291
+ casecmp.to_i.zero? 234.070k i/100ms
292
+ casecmp? 196.526k i/100ms
293
+ Calculating -------------------------------------
294
+ == to_s.downcase 5.061M (± 1.1%) i/s - 25.327M in 5.022350s
295
+ == casecmp 7.213M (± 0.8%) i/s - 36.045M in 5.009733s
296
+ casecmp.zero? 6.591M (± 0.9%) i/s - 33.011M in 5.021453s
297
+ casecmp.to_i.zero? 5.916M (± 0.9%) i/s - 29.727M in 5.039360s
298
+ casecmp? 4.462M (± 1.2%) i/s - 22.404M in 5.041505s
299
+ with 95.0% confidence
300
+
301
+ Comparison:
302
+ == casecmp: 7212692.8 i/s
303
+ casecmp.zero?: 6590791.5 i/s - 1.09x (± 0.01) slower
304
+ casecmp.to_i.zero?: 5915576.8 i/s - 1.22x (± 0.02) slower
305
+ == to_s.downcase: 5060645.9 i/s - 1.43x (± 0.02) slower
306
+ casecmp?: 4462174.0 i/s - 1.62x (± 0.02) slower
307
+ with 95.0% confidence
308
+ ```
309
+
310
+ #### Type Case: 123
311
+
312
+ ```
313
+ Warming up --------------------------------------
314
+ == to_s.downcase 194.578k i/100ms
315
+ == casecmp 162.422k i/100ms
316
+ casecmp.zero? 241.653k i/100ms
317
+ casecmp.to_i.zero? 225.119k i/100ms
318
+ casecmp? 240.602k i/100ms
319
+ Calculating -------------------------------------
320
+ == to_s.downcase 4.099M (± 1.0%) i/s - 20.625M in 5.045741s
321
+ == casecmp 3.068M (± 1.1%) i/s - 15.430M in 5.044417s
322
+ casecmp.zero? 6.334M (± 0.8%) i/s - 31.657M in 5.007791s
323
+ casecmp.to_i.zero? 5.284M (± 1.6%) i/s - 26.339M in 5.031971s
324
+ casecmp? 6.478M (± 1.0%) i/s - 32.481M in 5.031290s
325
+ with 95.0% confidence
326
+
327
+ Comparison:
328
+ casecmp?: 6478253.4 i/s
329
+ casecmp.zero?: 6333577.2 i/s - 1.02x (± 0.01) slower
330
+ casecmp.to_i.zero?: 5284198.7 i/s - 1.23x (± 0.02) slower
331
+ == to_s.downcase: 4098628.0 i/s - 1.58x (± 0.02) slower
332
+ == casecmp: 3067817.5 i/s - 2.11x (± 0.03) slower
333
+ with 95.0% confidence
334
+ ```
335
+
336
+ #### Type Case: #<Object:0x00007fcd219587b0>
337
+
338
+ ```
339
+ Warming up --------------------------------------
340
+ == to_s.downcase 52.158k i/100ms
341
+ == casecmp 163.492k i/100ms
342
+ casecmp.zero? 240.188k i/100ms
343
+ casecmp.to_i.zero? 226.153k i/100ms
344
+ casecmp? 236.788k i/100ms
345
+ Calculating -------------------------------------
346
+ == to_s.downcase 640.939k (± 1.1%) i/s - 3.234M in 5.053840s
347
+ == casecmp 3.075M (± 0.9%) i/s - 15.368M in 5.008669s
348
+ casecmp.zero? 6.623M (± 0.9%) i/s - 33.146M in 5.020333s
349
+ casecmp.to_i.zero? 5.376M (± 1.2%) i/s - 26.912M in 5.027477s
350
+ casecmp? 6.726M (± 1.0%) i/s - 33.624M in 5.016239s
351
+ with 95.0% confidence
352
+
353
+ Comparison:
354
+ casecmp?: 6726445.6 i/s
355
+ casecmp.zero?: 6623328.3 i/s - same-ish: difference falls within error
356
+ casecmp.to_i.zero?: 5376386.8 i/s - 1.25x (± 0.02) slower
357
+ == casecmp: 3074731.3 i/s - 2.19x (± 0.03) slower
358
+ == to_s.downcase: 640938.7 i/s - 10.49x (± 0.15) slower
359
+ with 95.0% confidence
360
+ ```
361
+
362
+ #### Type Case: #<StringLike:0x00007fcd21958788 @test_case="no match">
363
+
364
+ ```
365
+ Warming up --------------------------------------
366
+ == to_s.downcase 52.238k i/100ms
367
+ == casecmp 212.362k i/100ms
368
+ casecmp.zero? 207.266k i/100ms
369
+ casecmp.to_i.zero? 203.147k i/100ms
370
+ casecmp? 179.658k i/100ms
371
+ Calculating -------------------------------------
372
+ == to_s.downcase 649.352k (± 0.9%) i/s - 3.291M in 5.074729s
373
+ == casecmp 5.069M (± 0.9%) i/s - 25.483M in 5.039082s
374
+ casecmp.zero? 4.852M (± 0.9%) i/s - 24.250M in 5.011911s
375
+ casecmp.to_i.zero? 4.395M (± 1.1%) i/s - 21.940M in 5.009899s
376
+ casecmp? 3.443M (± 1.3%) i/s - 17.247M in 5.028774s
377
+ with 95.0% confidence
378
+
379
+ Comparison:
380
+ == casecmp: 5068628.3 i/s
381
+ casecmp.zero?: 4851650.8 i/s - 1.04x (± 0.01) slower
382
+ casecmp.to_i.zero?: 4394669.1 i/s - 1.15x (± 0.02) slower
383
+ casecmp?: 3443238.5 i/s - 1.47x (± 0.02) slower
384
+ == to_s.downcase: 649351.6 i/s - 7.81x (± 0.10) slower
385
+ with 95.0% confidence
386
+ ```
387
+
388
+ #### Type Case: #<StringLike:0x00007fcd21958760 @test_case="match">
389
+
390
+ ```
391
+ Warming up --------------------------------------
392
+ == to_s.downcase 53.698k i/100ms
393
+ == casecmp 211.054k i/100ms
394
+ casecmp.zero? 209.614k i/100ms
395
+ casecmp.to_i.zero? 205.111k i/100ms
396
+ casecmp? 177.677k i/100ms
397
+ Calculating -------------------------------------
398
+ == to_s.downcase 642.352k (± 1.1%) i/s - 3.222M in 5.024341s
399
+ == casecmp 4.801M (± 0.9%) i/s - 24.060M in 5.023696s
400
+ casecmp.zero? 4.509M (± 0.9%) i/s - 22.638M in 5.032909s
401
+ casecmp.to_i.zero? 4.450M (± 1.2%) i/s - 22.357M in 5.044182s
402
+ casecmp? 3.332M (± 1.1%) i/s - 16.702M in 5.028767s
403
+ with 95.0% confidence
404
+
405
+ Comparison:
406
+ == casecmp: 4801157.9 i/s
407
+ casecmp.zero?: 4508944.8 i/s - 1.06x (± 0.01) slower
408
+ casecmp.to_i.zero?: 4449914.9 i/s - 1.08x (± 0.02) slower
409
+ casecmp?: 3332042.5 i/s - 1.44x (± 0.02) slower
410
+ == to_s.downcase: 642351.9 i/s - 7.47x (± 0.11) slower
411
+ with 95.0% confidence
412
+ ```
413
+
414
+ #### Pre-check Case: nil
415
+
416
+ ```
417
+ Warming up --------------------------------------
418
+ == casecmp(to_s) 222.939k i/100ms
419
+ casecmp?(to_s) 188.102k i/100ms
420
+ casecmp? 236.868k i/100ms
421
+ falsey casecmp.zero? 279.966k i/100ms
422
+ falsey == casecmp 282.745k i/100ms
423
+ !! casecmp.zero? 266.091k i/100ms
424
+ !! == casecmp 266.932k i/100ms
425
+ nil? casecmp.zero? 272.193k i/100ms
426
+ nil? == casecmp 273.029k i/100ms
427
+ Calculating -------------------------------------
428
+ == casecmp(to_s) 4.937M (± 1.0%) i/s - 24.746M in 5.024918s
429
+ casecmp?(to_s) 3.589M (± 1.1%) i/s - 18.058M in 5.046262s
430
+ casecmp? 6.417M (± 1.2%) i/s - 31.977M in 5.007501s
431
+ falsey casecmp.zero? 9.773M (± 1.0%) i/s - 48.714M in 5.008779s
432
+ falsey == casecmp 10.045M (± 0.9%) i/s - 50.046M in 5.001595s
433
+ !! casecmp.zero? 9.330M (± 0.9%) i/s - 46.566M in 5.009468s
434
+ !! == casecmp 8.754M (± 2.1%) i/s - 42.442M in 5.001546s
435
+ nil? casecmp.zero? 8.716M (± 1.0%) i/s - 43.551M in 5.017106s
436
+ nil? == casecmp 8.596M (± 0.8%) i/s - 42.866M in 5.000683s
437
+ with 95.0% confidence
438
+
439
+ Comparison:
440
+ falsey == casecmp: 10045375.1 i/s
441
+ falsey casecmp.zero?: 9772608.7 i/s - 1.03x (± 0.01) slower
442
+ !! casecmp.zero?: 9330161.0 i/s - 1.08x (± 0.01) slower
443
+ !! == casecmp: 8754421.4 i/s - 1.15x (± 0.03) slower
444
+ nil? casecmp.zero?: 8715727.1 i/s - 1.15x (± 0.02) slower
445
+ nil? == casecmp: 8595661.2 i/s - 1.17x (± 0.01) slower
446
+ casecmp?: 6417121.6 i/s - 1.57x (± 0.02) slower
447
+ == casecmp(to_s): 4936724.1 i/s - 2.03x (± 0.03) slower
448
+ casecmp?(to_s): 3588687.7 i/s - 2.80x (± 0.04) slower
449
+ with 95.0% confidence
450
+ ```
451
+
452
+ #### Pre-check Case: "no match"
453
+
454
+ ```
455
+ Warming up --------------------------------------
456
+ == casecmp(to_s) 245.036k i/100ms
457
+ casecmp?(to_s) 196.918k i/100ms
458
+ casecmp? 208.835k i/100ms
459
+ falsey casecmp.zero? 252.889k i/100ms
460
+ falsey == casecmp 253.206k i/100ms
461
+ !! casecmp.zero? 237.682k i/100ms
462
+ !! == casecmp 237.849k i/100ms
463
+ nil? casecmp.zero? 235.435k i/100ms
464
+ nil? == casecmp 242.031k i/100ms
465
+ Calculating -------------------------------------
466
+ == casecmp(to_s) 6.598M (± 1.0%) i/s - 33.080M in 5.031444s
467
+ casecmp?(to_s) 4.044M (± 1.2%) i/s - 20.283M in 5.036826s
468
+ casecmp? 4.503M (± 0.9%) i/s - 22.554M in 5.019573s
469
+ falsey casecmp.zero? 6.692M (± 0.8%) i/s - 33.634M in 5.036615s
470
+ falsey == casecmp 7.031M (± 0.9%) i/s - 35.196M in 5.018913s
471
+ !! casecmp.zero? 6.074M (± 1.1%) i/s - 30.423M in 5.029842s
472
+ !! == casecmp 6.146M (± 0.8%) i/s - 30.683M in 5.001632s
473
+ nil? casecmp.zero? 5.891M (± 0.8%) i/s - 29.429M in 5.006134s
474
+ nil? == casecmp 6.238M (± 0.8%) i/s - 31.222M in 5.015890s
475
+ with 95.0% confidence
476
+
477
+ Comparison:
478
+ falsey == casecmp: 7031044.2 i/s
479
+ falsey casecmp.zero?: 6691656.4 i/s - 1.05x (± 0.01) slower
480
+ == casecmp(to_s): 6598167.5 i/s - 1.07x (± 0.01) slower
481
+ nil? == casecmp: 6237735.7 i/s - 1.13x (± 0.01) slower
482
+ !! == casecmp: 6146232.8 i/s - 1.14x (± 0.01) slower
483
+ !! casecmp.zero?: 6073969.3 i/s - 1.16x (± 0.02) slower
484
+ nil? casecmp.zero?: 5890972.7 i/s - 1.19x (± 0.01) slower
485
+ casecmp?: 4503136.8 i/s - 1.56x (± 0.02) slower
486
+ casecmp?(to_s): 4043637.6 i/s - 1.74x (± 0.03) slower
487
+ with 95.0% confidence
488
+ ```