radius-spec 0.2.0 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +6 -0
- data/.travis.yml +4 -5
- data/.yardopts +1 -0
- data/CHANGELOG.md +122 -1
- data/Gemfile +9 -5
- data/README.md +352 -34
- data/benchmarks/bm_setup.rb +70 -0
- data/benchmarks/call_vs_yield.rb +181 -0
- data/benchmarks/case_equality_vs_class_check.rb +73 -0
- data/benchmarks/casecmp_vs_downcase.rb +488 -0
- data/benchmarks/cover_vs_include.rb +106 -0
- data/benchmarks/delete_vs_tr.rb +100 -0
- data/benchmarks/double_negation.rb +167 -0
- data/benchmarks/empty_literal.rb +75 -0
- data/benchmarks/format_string.rb +58 -0
- data/benchmarks/format_string_token.rb +160 -0
- data/benchmarks/gsub_vs_tr.rb +95 -0
- data/benchmarks/hash_merge.rb +112 -0
- data/benchmarks/kwargs.rb +159 -0
- data/benchmarks/max_ternary.rb +105 -0
- data/benchmarks/max_ternary_micro.rb +129 -0
- data/benchmarks/unfreeze_string.rb +86 -0
- data/benchmarks/unpack_first.rb +54 -0
- data/bin/ci +2 -2
- data/bin/ci-code-review +28 -0
- data/common_rubocop.yml +270 -32
- data/common_rubocop_rails.yml +127 -13
- data/lib/radius/spec/model_factory.rb +35 -22
- data/lib/radius/spec/rails.rb +2 -2
- data/lib/radius/spec/rspec.rb +20 -0
- data/lib/radius/spec/rspec/negated_matchers.rb +19 -0
- data/lib/radius/spec/tempfile.rb +162 -0
- data/lib/radius/spec/vcr.rb +100 -0
- data/lib/radius/spec/version.rb +1 -1
- data/radius-spec.gemspec +1 -0
- metadata +43 -10
- data/bin/travis +0 -29
@@ -0,0 +1,58 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Run from the command line: bundle exec ruby benchmarks/format_string.rb
|
4
|
+
require_relative 'bm_setup'
|
5
|
+
|
6
|
+
display_benchmark_header
|
7
|
+
|
8
|
+
SINGLE_TOKEN_HASH = { greeting: 'Hello' }.freeze
|
9
|
+
MULTI_TOKEN_HASH = {
|
10
|
+
greeting: 'Hello',
|
11
|
+
name: 'Benchmark',
|
12
|
+
message: 'Always a good idea to benchmark',
|
13
|
+
}.freeze
|
14
|
+
|
15
|
+
# rubocop:disable Style/FormatString
|
16
|
+
section "Format String" do |bench|
|
17
|
+
bench.report("String#%") do
|
18
|
+
'%10s' % 'hoge'
|
19
|
+
end
|
20
|
+
|
21
|
+
bench.report("format") do
|
22
|
+
format '%10s', 'hoge'
|
23
|
+
end
|
24
|
+
|
25
|
+
bench.report("sprintf") do
|
26
|
+
sprintf '%10s', 'hoge'
|
27
|
+
end
|
28
|
+
end
|
29
|
+
# rubocop:enable Style/FormatString
|
30
|
+
|
31
|
+
__END__
|
32
|
+
|
33
|
+
### Environment
|
34
|
+
|
35
|
+
ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-darwin16]
|
36
|
+
GC Disabled: false
|
37
|
+
|
38
|
+
### Test Cases
|
39
|
+
|
40
|
+
#### Format String
|
41
|
+
|
42
|
+
```
|
43
|
+
Warming up --------------------------------------
|
44
|
+
String#% 148.922k i/100ms
|
45
|
+
format 162.561k i/100ms
|
46
|
+
sprintf 157.745k i/100ms
|
47
|
+
Calculating -------------------------------------
|
48
|
+
String#% 2.363M (± 0.8%) i/s - 11.914M in 5.049141s
|
49
|
+
format 2.668M (± 0.8%) i/s - 13.330M in 5.002105s
|
50
|
+
sprintf 2.609M (± 0.8%) i/s - 13.093M in 5.025561s
|
51
|
+
with 95.0% confidence
|
52
|
+
|
53
|
+
Comparison:
|
54
|
+
format: 2668054.9 i/s
|
55
|
+
sprintf: 2609234.8 i/s - 1.02x (± 0.01) slower
|
56
|
+
String#%: 2363040.2 i/s - 1.13x (± 0.01) slower
|
57
|
+
with 95.0% confidence
|
58
|
+
```
|
@@ -0,0 +1,160 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Run from the command line: bundle exec ruby benchmarks/format_string_token.rb
|
4
|
+
require_relative 'bm_setup'
|
5
|
+
|
6
|
+
display_benchmark_header
|
7
|
+
|
8
|
+
SINGLE_TOKEN_HASH = { greeting: 'Hello' }.freeze
|
9
|
+
MULTI_TOKEN_HASH = {
|
10
|
+
greeting: 'Hello',
|
11
|
+
name: 'Benchmark',
|
12
|
+
message: 'Always a good idea to benchmark',
|
13
|
+
}.freeze
|
14
|
+
|
15
|
+
# rubocop:disable Style/FormatStringToken
|
16
|
+
section "Format String Token (single token - inline token hash)" do |bench|
|
17
|
+
bench.report("annotated") do
|
18
|
+
format '%<greeting>s', greeting: 'Hello'
|
19
|
+
end
|
20
|
+
|
21
|
+
bench.report("template") do
|
22
|
+
format '%{greeting}', greeting: 'Hello'
|
23
|
+
end
|
24
|
+
|
25
|
+
bench.report("unannotated") do
|
26
|
+
format '%s', 'Hello'
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
section "Format String Token (single token - constant token hash)" do |bench|
|
31
|
+
bench.report("annotated") do
|
32
|
+
format '%<greeting>s', SINGLE_TOKEN_HASH
|
33
|
+
end
|
34
|
+
|
35
|
+
bench.report("template") do
|
36
|
+
format '%{greeting}', SINGLE_TOKEN_HASH
|
37
|
+
end
|
38
|
+
|
39
|
+
bench.report("unannotated") do
|
40
|
+
format '%s', 'Hello'
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
section "Format String Token (multiple tokens - constant token hash)" do |bench|
|
45
|
+
bench.report("annotated") do
|
46
|
+
format '%<greeting>s %<name>s, %<message>s!', MULTI_TOKEN_HASH
|
47
|
+
end
|
48
|
+
|
49
|
+
bench.report("template") do
|
50
|
+
format '%{greeting} %{name}, %{message}!', MULTI_TOKEN_HASH
|
51
|
+
end
|
52
|
+
|
53
|
+
bench.report("unannotated") do
|
54
|
+
format '%s %s, %s', 'Hello', 'Benchmark!', 'Always a good idea to benchmark'
|
55
|
+
end
|
56
|
+
end
|
57
|
+
# rubocop:enable Style/FormatStringToken
|
58
|
+
|
59
|
+
section "Format String Token (annotated)" do |bench|
|
60
|
+
bench.report("inline hash") do
|
61
|
+
format '%<greeting>s', greeting: 'Hello'
|
62
|
+
end
|
63
|
+
|
64
|
+
bench.report("constant hash") do
|
65
|
+
format '%<greeting>s', SINGLE_TOKEN_HASH
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
__END__
|
70
|
+
|
71
|
+
### Environment
|
72
|
+
|
73
|
+
ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-darwin16]
|
74
|
+
GC Disabled: false
|
75
|
+
|
76
|
+
### Test Cases
|
77
|
+
|
78
|
+
#### Format String Token (single token - inline token hash)
|
79
|
+
|
80
|
+
```
|
81
|
+
Warming up --------------------------------------
|
82
|
+
annotated 88.435k i/100ms
|
83
|
+
template 87.693k i/100ms
|
84
|
+
unannotated 173.134k i/100ms
|
85
|
+
Calculating -------------------------------------
|
86
|
+
annotated 1.160M (± 1.3%) i/s - 5.837M in 5.044452s
|
87
|
+
template 1.188M (± 1.2%) i/s - 5.963M in 5.031961s
|
88
|
+
unannotated 3.053M (± 0.8%) i/s - 15.409M in 5.055505s
|
89
|
+
with 95.0% confidence
|
90
|
+
|
91
|
+
Comparison:
|
92
|
+
unannotated: 3053228.5 i/s
|
93
|
+
template: 1187997.4 i/s - 2.57x (± 0.04) slower
|
94
|
+
annotated: 1160462.9 i/s - 2.63x (± 0.04) slower
|
95
|
+
with 95.0% confidence
|
96
|
+
```
|
97
|
+
|
98
|
+
#### Format String Token (single token - constant token hash)
|
99
|
+
|
100
|
+
```
|
101
|
+
Warming up --------------------------------------
|
102
|
+
annotated 142.944k i/100ms
|
103
|
+
template 142.146k i/100ms
|
104
|
+
unannotated 178.653k i/100ms
|
105
|
+
Calculating -------------------------------------
|
106
|
+
annotated 2.155M (± 0.8%) i/s - 10.864M in 5.048122s
|
107
|
+
template 2.158M (± 1.0%) i/s - 10.803M in 5.016911s
|
108
|
+
unannotated 3.081M (± 0.8%) i/s - 15.543M in 5.053055s
|
109
|
+
with 95.0% confidence
|
110
|
+
|
111
|
+
Comparison:
|
112
|
+
unannotated: 3080897.8 i/s
|
113
|
+
template: 2157563.3 i/s - 1.43x (± 0.02) slower
|
114
|
+
annotated: 2155420.1 i/s - 1.43x (± 0.02) slower
|
115
|
+
with 95.0% confidence
|
116
|
+
```
|
117
|
+
|
118
|
+
#### Format String Token (multiple tokens - constant token hash)
|
119
|
+
|
120
|
+
```
|
121
|
+
Warming up --------------------------------------
|
122
|
+
annotated 69.462k i/100ms
|
123
|
+
template 59.389k i/100ms
|
124
|
+
unannotated 57.845k i/100ms
|
125
|
+
Calculating -------------------------------------
|
126
|
+
annotated 890.828k (± 3.4%) i/s - 4.307M in 5.042996s
|
127
|
+
template 885.637k (± 2.8%) i/s - 4.276M in 5.017872s
|
128
|
+
unannotated 1.343M (± 3.8%) i/s - 6.189M in 5.104055s
|
129
|
+
with 95.0% confidence
|
130
|
+
|
131
|
+
Comparison:
|
132
|
+
unannotated: 1342803.3 i/s
|
133
|
+
annotated: 890828.1 i/s - 1.51x (± 0.08) slower
|
134
|
+
template: 885637.5 i/s - 1.52x (± 0.07) slower
|
135
|
+
with 95.0% confidence
|
136
|
+
```
|
137
|
+
|
138
|
+
### Environment
|
139
|
+
|
140
|
+
ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-darwin16]
|
141
|
+
GC Disabled: false
|
142
|
+
|
143
|
+
### Test Cases
|
144
|
+
|
145
|
+
#### Format String Token (annotated)
|
146
|
+
|
147
|
+
```
|
148
|
+
Warming up --------------------------------------
|
149
|
+
inline hash 91.059k i/100ms
|
150
|
+
constant hash 135.572k i/100ms
|
151
|
+
Calculating -------------------------------------
|
152
|
+
inline hash 1.218M (± 1.2%) i/s - 6.101M in 5.024187s
|
153
|
+
constant hash 2.135M (± 1.0%) i/s - 10.710M in 5.028115s
|
154
|
+
with 95.0% confidence
|
155
|
+
|
156
|
+
Comparison:
|
157
|
+
constant hash: 2135050.5 i/s
|
158
|
+
inline hash: 1217810.2 i/s - 1.75x (± 0.03) slower
|
159
|
+
with 95.0% confidence
|
160
|
+
```
|
@@ -0,0 +1,95 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Run from the command line: bundle exec ruby benchmarks/gsub_vs_tr.rb
|
4
|
+
require_relative 'bm_setup'
|
5
|
+
|
6
|
+
display_benchmark_header
|
7
|
+
|
8
|
+
[
|
9
|
+
["No Replacement", "Any String", "m", /m/, "-"],
|
10
|
+
["Single Replacement", "Any String", "i", /i/, "-"],
|
11
|
+
["Multiple Replacement", "Any String", "n", /n/, "-"],
|
12
|
+
].each do |title, str, pattern, regexp, replacement|
|
13
|
+
section title do |bench|
|
14
|
+
bench.report("gsub(string)") do
|
15
|
+
str.gsub(pattern, replacement)
|
16
|
+
end
|
17
|
+
|
18
|
+
bench.report("gsub(regexp)") do
|
19
|
+
str.gsub(regexp, replacement)
|
20
|
+
end
|
21
|
+
|
22
|
+
bench.report("tr") do
|
23
|
+
str.tr(pattern, replacement)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
__END__
|
29
|
+
|
30
|
+
### Environment
|
31
|
+
|
32
|
+
ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-darwin16]
|
33
|
+
GC Disabled: false
|
34
|
+
|
35
|
+
### Test Cases
|
36
|
+
|
37
|
+
#### No Replacement
|
38
|
+
|
39
|
+
```
|
40
|
+
Warming up --------------------------------------
|
41
|
+
gsub(string) 225.903k i/100ms
|
42
|
+
gsub(regexp) 150.469k i/100ms
|
43
|
+
tr 225.874k i/100ms
|
44
|
+
Calculating -------------------------------------
|
45
|
+
gsub(string) 4.848M (± 0.7%) i/s - 24.398M in 5.042073s
|
46
|
+
gsub(regexp) 2.558M (± 1.3%) i/s - 12.790M in 5.018370s
|
47
|
+
tr 4.872M (± 1.0%) i/s - 24.394M in 5.020983s
|
48
|
+
with 95.0% confidence
|
49
|
+
|
50
|
+
Comparison:
|
51
|
+
tr: 4872264.7 i/s
|
52
|
+
gsub(string): 4847903.4 i/s - same-ish: difference falls within error
|
53
|
+
gsub(regexp): 2557821.1 i/s - 1.91x (± 0.03) slower
|
54
|
+
with 95.0% confidence
|
55
|
+
```
|
56
|
+
|
57
|
+
#### Single Replacement
|
58
|
+
|
59
|
+
```
|
60
|
+
Warming up --------------------------------------
|
61
|
+
gsub(string) 115.202k i/100ms
|
62
|
+
gsub(regexp) 64.609k i/100ms
|
63
|
+
tr 230.643k i/100ms
|
64
|
+
Calculating -------------------------------------
|
65
|
+
gsub(string) 1.431M (± 1.6%) i/s - 7.143M in 5.010792s
|
66
|
+
gsub(regexp) 663.965k (± 1.0%) i/s - 3.360M in 5.067248s
|
67
|
+
tr 4.517M (± 0.9%) i/s - 22.603M in 5.014505s
|
68
|
+
with 95.0% confidence
|
69
|
+
|
70
|
+
Comparison:
|
71
|
+
tr: 4516906.0 i/s
|
72
|
+
gsub(string): 1430926.3 i/s - 3.16x (± 0.06) slower
|
73
|
+
gsub(regexp): 663964.7 i/s - 6.80x (± 0.09) slower
|
74
|
+
with 95.0% confidence
|
75
|
+
```
|
76
|
+
|
77
|
+
#### Multiple Replacement
|
78
|
+
|
79
|
+
```
|
80
|
+
Warming up --------------------------------------
|
81
|
+
gsub(string) 92.833k i/100ms
|
82
|
+
gsub(regexp) 51.482k i/100ms
|
83
|
+
tr 222.779k i/100ms
|
84
|
+
Calculating -------------------------------------
|
85
|
+
gsub(string) 1.263M (± 1.3%) i/s - 6.313M in 5.014495s
|
86
|
+
gsub(regexp) 663.557k (± 1.4%) i/s - 3.346M in 5.061408s
|
87
|
+
tr 4.786M (± 0.9%) i/s - 24.060M in 5.040074s
|
88
|
+
with 95.0% confidence
|
89
|
+
|
90
|
+
Comparison:
|
91
|
+
tr: 4785813.8 i/s
|
92
|
+
gsub(string): 1262609.0 i/s - 3.79x (± 0.06) slower
|
93
|
+
gsub(regexp): 663557.0 i/s - 7.21x (± 0.12) slower
|
94
|
+
with 95.0% confidence
|
95
|
+
```
|
@@ -0,0 +1,112 @@
|
|
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
|
+
ENUM = (1..100)
|
9
|
+
|
10
|
+
def hash_merge
|
11
|
+
tmp = {}
|
12
|
+
ENUM.each do |e|
|
13
|
+
tmp.merge! e => e
|
14
|
+
end
|
15
|
+
tmp
|
16
|
+
end
|
17
|
+
|
18
|
+
def hash_assign
|
19
|
+
tmp = {}
|
20
|
+
ENUM.each do |e|
|
21
|
+
tmp[e] = e
|
22
|
+
end
|
23
|
+
tmp
|
24
|
+
end
|
25
|
+
|
26
|
+
COMPOSE = {
|
27
|
+
a: 'a',
|
28
|
+
b: 'b',
|
29
|
+
c: 'c',
|
30
|
+
}.freeze
|
31
|
+
|
32
|
+
def hash_compose_merge
|
33
|
+
{ one: 1 }.merge(COMPOSE)
|
34
|
+
end
|
35
|
+
|
36
|
+
def hash_compose_merge!
|
37
|
+
{ one: 1 }.merge!(COMPOSE)
|
38
|
+
end
|
39
|
+
|
40
|
+
def hash_compose_splat
|
41
|
+
{ one: 1, **COMPOSE }
|
42
|
+
end
|
43
|
+
|
44
|
+
section "Hash merge vs assign" do |bench|
|
45
|
+
bench.report("Hash#merge!") do
|
46
|
+
hash_merge
|
47
|
+
end
|
48
|
+
|
49
|
+
bench.report("Hash#[]=") do
|
50
|
+
hash_assign
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
section "Hash compose: merge vs splat" do |bench|
|
55
|
+
bench.report("merge") do
|
56
|
+
hash_compose_merge
|
57
|
+
end
|
58
|
+
|
59
|
+
bench.report("merge!") do
|
60
|
+
hash_compose_merge!
|
61
|
+
end
|
62
|
+
|
63
|
+
bench.report("splat") do
|
64
|
+
hash_compose_splat
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
__END__
|
69
|
+
|
70
|
+
### Environment
|
71
|
+
|
72
|
+
ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-darwin16]
|
73
|
+
GC Disabled: false
|
74
|
+
|
75
|
+
### Test Cases
|
76
|
+
|
77
|
+
#### Hash merge vs assign
|
78
|
+
|
79
|
+
```
|
80
|
+
Warming up --------------------------------------
|
81
|
+
Hash#merge! 1.760k i/100ms
|
82
|
+
Hash#[]= 7.821k i/100ms
|
83
|
+
Calculating -------------------------------------
|
84
|
+
Hash#merge! 17.746k (± 1.1%) i/s - 89.760k in 5.065762s
|
85
|
+
Hash#[]= 83.691k (± 1.2%) i/s - 422.334k in 5.057697s
|
86
|
+
with 95.0% confidence
|
87
|
+
|
88
|
+
Comparison:
|
89
|
+
Hash#[]=: 83691.2 i/s
|
90
|
+
Hash#merge!: 17746.3 i/s - 4.71x (± 0.08) slower
|
91
|
+
with 95.0% confidence
|
92
|
+
```
|
93
|
+
|
94
|
+
#### Hash compose: merge vs splat
|
95
|
+
|
96
|
+
```
|
97
|
+
Warming up --------------------------------------
|
98
|
+
merge 78.448k i/100ms
|
99
|
+
merge! 111.435k i/100ms
|
100
|
+
splat 111.927k i/100ms
|
101
|
+
Calculating -------------------------------------
|
102
|
+
merge 978.337k (± 1.0%) i/s - 4.942M in 5.061428s
|
103
|
+
merge! 1.571M (± 1.0%) i/s - 7.912M in 5.046875s
|
104
|
+
splat 1.587M (± 1.0%) i/s - 7.947M in 5.017037s
|
105
|
+
with 95.0% confidence
|
106
|
+
|
107
|
+
Comparison:
|
108
|
+
splat: 1587073.4 i/s
|
109
|
+
merge!: 1570636.9 i/s - same-ish: difference falls within error
|
110
|
+
merge: 978337.3 i/s - 1.62x (± 0.02) slower
|
111
|
+
with 95.0% confidence
|
112
|
+
```
|
@@ -0,0 +1,159 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Run from the command line: bundle exec ruby benchmarks/kwargs.rb
|
4
|
+
require_relative 'bm_setup'
|
5
|
+
|
6
|
+
display_benchmark_header
|
7
|
+
|
8
|
+
NAME = "any name"
|
9
|
+
STATIC_OPTS = { name: "any name" }.freeze
|
10
|
+
|
11
|
+
def hash_param(hash)
|
12
|
+
hash
|
13
|
+
end
|
14
|
+
|
15
|
+
def kwarg_param(name: nil)
|
16
|
+
name
|
17
|
+
end
|
18
|
+
|
19
|
+
def kwarg_splat_param(**kwargs)
|
20
|
+
kwargs
|
21
|
+
end
|
22
|
+
|
23
|
+
def static_opts
|
24
|
+
kwarg_param STATIC_OPTS
|
25
|
+
end
|
26
|
+
|
27
|
+
def named_opts
|
28
|
+
kwarg_param name: NAME
|
29
|
+
end
|
30
|
+
|
31
|
+
def splat_opts
|
32
|
+
kwarg_splat_param name: NAME
|
33
|
+
end
|
34
|
+
|
35
|
+
def hash_opts
|
36
|
+
hash_param name: NAME
|
37
|
+
end
|
38
|
+
|
39
|
+
section "kwargs vs hash method" do |x|
|
40
|
+
x.report("hash param") do
|
41
|
+
hash_opts
|
42
|
+
end
|
43
|
+
|
44
|
+
x.report("kwarg param") do
|
45
|
+
named_opts
|
46
|
+
end
|
47
|
+
|
48
|
+
x.report("kwarg splat param") do
|
49
|
+
splat_opts
|
50
|
+
end
|
51
|
+
|
52
|
+
x.compare!
|
53
|
+
end
|
54
|
+
|
55
|
+
section "Call kwargs method" do |x|
|
56
|
+
x.report("static opts") do
|
57
|
+
static_opts
|
58
|
+
end
|
59
|
+
|
60
|
+
x.report("named opts") do
|
61
|
+
named_opts
|
62
|
+
end
|
63
|
+
|
64
|
+
x.compare!
|
65
|
+
end
|
66
|
+
|
67
|
+
__END__
|
68
|
+
|
69
|
+
Perhaps surprisingly the kwarg parameters option is much faster. I'm not sure
|
70
|
+
why this actually is, but my guess is that Ruby optimizes this during the byte
|
71
|
+
code process.
|
72
|
+
|
73
|
+
### Environment
|
74
|
+
|
75
|
+
ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-darwin16]
|
76
|
+
GC Disabled: false
|
77
|
+
|
78
|
+
### Test Cases
|
79
|
+
|
80
|
+
#### kwargs vs hash method
|
81
|
+
|
82
|
+
```
|
83
|
+
Warming up --------------------------------------
|
84
|
+
hash param 131.753k i/100ms
|
85
|
+
kwarg param 266.657k i/100ms
|
86
|
+
kwarg splat param 66.641k i/100ms
|
87
|
+
Calculating -------------------------------------
|
88
|
+
hash param 2.057M (± 1.6%) i/s - 10.277M in 5.023252s
|
89
|
+
kwarg param 7.351M (± 0.7%) i/s - 36.799M in 5.015356s
|
90
|
+
kwarg splat param 850.179k (± 1.4%) i/s - 4.265M in 5.035194s
|
91
|
+
with 95.0% confidence
|
92
|
+
|
93
|
+
Comparison:
|
94
|
+
kwarg param: 7351007.8 i/s
|
95
|
+
hash param: 2056501.2 i/s - 3.57x (± 0.06) slower
|
96
|
+
kwarg splat param: 850179.4 i/s - 8.64x (± 0.13) slower
|
97
|
+
with 95.0% confidence
|
98
|
+
```
|
99
|
+
|
100
|
+
#### Call kwargs method
|
101
|
+
|
102
|
+
```
|
103
|
+
Warming up --------------------------------------
|
104
|
+
static opts 127.699k i/100ms
|
105
|
+
named opts 274.978k i/100ms
|
106
|
+
Calculating -------------------------------------
|
107
|
+
static opts 1.879M (± 1.0%) i/s - 9.450M in 5.039627s
|
108
|
+
named opts 6.938M (± 1.1%) i/s - 34.647M in 5.014500s
|
109
|
+
with 95.0% confidence
|
110
|
+
|
111
|
+
Comparison:
|
112
|
+
named opts: 6937888.3 i/s
|
113
|
+
static opts: 1878705.6 i/s - 3.69x (± 0.05) 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
|
+
#### kwargs vs hash method
|
125
|
+
|
126
|
+
```
|
127
|
+
Warming up --------------------------------------
|
128
|
+
hash param 144.722k i/100ms
|
129
|
+
kwarg param 266.216k i/100ms
|
130
|
+
kwarg splat param 67.212k i/100ms
|
131
|
+
Calculating -------------------------------------
|
132
|
+
hash param 2.318M (± 5.2%) i/s - 10.709M in 5.017846s
|
133
|
+
kwarg param 7.381M (± 0.8%) i/s - 37.004M in 5.026198s
|
134
|
+
kwarg splat param 893.963k (±15.1%) i/s - 3.159M in 5.180853s
|
135
|
+
with 95.0% confidence
|
136
|
+
|
137
|
+
Comparison:
|
138
|
+
kwarg param: 7380700.1 i/s
|
139
|
+
hash param: 2317626.6 i/s - 3.19x (± 0.17) slower
|
140
|
+
kwarg splat param: 893963.2 i/s - 8.26x (± 1.26) slower
|
141
|
+
with 95.0% confidence
|
142
|
+
```
|
143
|
+
|
144
|
+
#### Call kwargs method
|
145
|
+
|
146
|
+
```
|
147
|
+
Warming up --------------------------------------
|
148
|
+
static opts 157.568k i/100ms
|
149
|
+
named opts 271.741k i/100ms
|
150
|
+
Calculating -------------------------------------
|
151
|
+
static opts 1.741M (±12.7%) i/s - 7.091M in 5.038616s
|
152
|
+
named opts 7.335M (± 0.7%) i/s - 36.685M in 5.010800s
|
153
|
+
with 95.0% confidence
|
154
|
+
|
155
|
+
Comparison:
|
156
|
+
named opts: 7335402.3 i/s
|
157
|
+
static opts: 1740760.5 i/s - 4.21x (± 0.53) slower
|
158
|
+
with 95.0% confidence
|
159
|
+
```
|