radius-spec 0.2.1 → 0.3.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.
- checksums.yaml +4 -4
- data/.rubocop.yml +1 -0
- data/.travis.yml +2 -0
- data/CHANGELOG.md +24 -0
- data/Gemfile +7 -4
- data/benchmarks/bm_setup.rb +69 -0
- data/benchmarks/call_vs_yield.rb +148 -0
- data/benchmarks/case_equality_vs_class_check.rb +73 -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 +1 -1
- data/bin/ci-code-review +28 -0
- data/common_rubocop.yml +83 -14
- data/lib/radius/spec/version.rb +1 -1
- data/radius-spec.gemspec +1 -0
- metadata +35 -4
@@ -0,0 +1,100 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Run from the command line: bundle exec ruby benchmarks/delete_vs_tr.rb
|
4
|
+
require_relative 'bm_setup'
|
5
|
+
|
6
|
+
display_benchmark_header
|
7
|
+
|
8
|
+
[
|
9
|
+
["No Removal", "Any String Chars", "m", ""],
|
10
|
+
["Single Removal", "Any String Chars", "i", ""],
|
11
|
+
["Multiple Removal", "Any String Chars", "n", ""],
|
12
|
+
["Multi-Char Removal", "Any String Chars", "nar", ""],
|
13
|
+
].each do |title, str, pattern, replacement|
|
14
|
+
section title do |bench|
|
15
|
+
bench.report("delete") do
|
16
|
+
str.delete(pattern)
|
17
|
+
end
|
18
|
+
|
19
|
+
bench.report("tr") do
|
20
|
+
str.tr(pattern, replacement)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
__END__
|
26
|
+
|
27
|
+
### Environment
|
28
|
+
|
29
|
+
ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-darwin16]
|
30
|
+
GC Disabled: false
|
31
|
+
|
32
|
+
### Test Cases
|
33
|
+
|
34
|
+
#### No Removal
|
35
|
+
|
36
|
+
```
|
37
|
+
Warming up --------------------------------------
|
38
|
+
delete 164.989k i/100ms
|
39
|
+
tr 163.504k i/100ms
|
40
|
+
Calculating -------------------------------------
|
41
|
+
delete 2.578M (± 0.9%) i/s - 13.034M in 5.065099s
|
42
|
+
tr 2.566M (± 0.8%) i/s - 12.917M in 5.039546s
|
43
|
+
with 95.0% confidence
|
44
|
+
|
45
|
+
Comparison:
|
46
|
+
delete: 2578043.5 i/s
|
47
|
+
tr: 2565794.9 i/s - same-ish: difference falls within error
|
48
|
+
with 95.0% confidence
|
49
|
+
```
|
50
|
+
|
51
|
+
#### Single Removal
|
52
|
+
|
53
|
+
```
|
54
|
+
Warming up --------------------------------------
|
55
|
+
delete 169.321k i/100ms
|
56
|
+
tr 173.594k i/100ms
|
57
|
+
Calculating -------------------------------------
|
58
|
+
delete 2.779M (± 1.1%) i/s - 13.884M in 5.010559s
|
59
|
+
tr 2.721M (± 1.0%) i/s - 13.714M in 5.050566s
|
60
|
+
with 95.0% confidence
|
61
|
+
|
62
|
+
Comparison:
|
63
|
+
delete: 2778762.2 i/s
|
64
|
+
tr: 2721121.1 i/s - 1.02x (± 0.02) slower
|
65
|
+
with 95.0% confidence
|
66
|
+
```
|
67
|
+
|
68
|
+
#### Multiple Removal
|
69
|
+
|
70
|
+
```
|
71
|
+
Warming up --------------------------------------
|
72
|
+
delete 173.074k i/100ms
|
73
|
+
tr 171.824k i/100ms
|
74
|
+
Calculating -------------------------------------
|
75
|
+
delete 2.804M (± 1.0%) i/s - 14.019M in 5.009616s
|
76
|
+
tr 2.739M (± 1.0%) i/s - 13.746M in 5.030533s
|
77
|
+
with 95.0% confidence
|
78
|
+
|
79
|
+
Comparison:
|
80
|
+
delete: 2804348.9 i/s
|
81
|
+
tr: 2739399.1 i/s - 1.02x (± 0.01) slower
|
82
|
+
with 95.0% confidence
|
83
|
+
```
|
84
|
+
|
85
|
+
#### Multi-Char Removal
|
86
|
+
|
87
|
+
```
|
88
|
+
Warming up --------------------------------------
|
89
|
+
delete 165.485k i/100ms
|
90
|
+
tr 158.961k i/100ms
|
91
|
+
Calculating -------------------------------------
|
92
|
+
delete 2.547M (± 1.3%) i/s - 12.742M in 5.019971s
|
93
|
+
tr 2.507M (± 1.0%) i/s - 12.558M in 5.018688s
|
94
|
+
with 95.0% confidence
|
95
|
+
|
96
|
+
Comparison:
|
97
|
+
delete: 2547442.6 i/s
|
98
|
+
tr: 2507427.2 i/s - same-ish: difference falls within error
|
99
|
+
with 95.0% confidence
|
100
|
+
```
|
@@ -0,0 +1,167 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Run from the command line: bundle exec ruby benchmarks/double_negation.rb
|
4
|
+
require_relative 'bm_setup'
|
5
|
+
require 'active_support'
|
6
|
+
require 'active_support/core_ext/object/blank'
|
7
|
+
|
8
|
+
display_benchmark_header
|
9
|
+
|
10
|
+
# rubocop:disable Style/NonNilCheck
|
11
|
+
# As this is basically a micro-benchmark we use the block with `while` idiom
|
12
|
+
[nil, [], Object.new].each do |x|
|
13
|
+
section x.inspect do |bench|
|
14
|
+
bench.report("!!") do |times|
|
15
|
+
i = 0
|
16
|
+
while i < times
|
17
|
+
!!x
|
18
|
+
i += 1
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
bench.report("!nil?") do |times|
|
23
|
+
i = 0
|
24
|
+
while i < times
|
25
|
+
!x.nil?
|
26
|
+
i += 1
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
bench.report("nil !=") do |times|
|
31
|
+
i = 0
|
32
|
+
while i < times
|
33
|
+
nil != x
|
34
|
+
i += 1
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
bench.report("present?") do |times|
|
39
|
+
i = 0
|
40
|
+
while i < times
|
41
|
+
x.present?
|
42
|
+
i += 1
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
# When performing the initial testing we used `x == nil`. However, that was
|
49
|
+
# shockingly slow for the empty array case. Because of that we inverted the
|
50
|
+
# conditional in the above condition. However, as proof of this oddity and to
|
51
|
+
# allow us to track behavior in future versions we include this additional
|
52
|
+
# benchmark showing the issue.
|
53
|
+
section "Empty array `nil` comparison" do |bench|
|
54
|
+
x = []
|
55
|
+
|
56
|
+
bench.report("!= nil") do |times|
|
57
|
+
i = 0
|
58
|
+
while i < times
|
59
|
+
nil != x
|
60
|
+
i += 1
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
bench.report("nil !=") do |times|
|
65
|
+
i = 0
|
66
|
+
while i < times
|
67
|
+
x != nil
|
68
|
+
i += 1
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
# rubocop:enable Style/NonNilCheck
|
73
|
+
|
74
|
+
__END__
|
75
|
+
|
76
|
+
### Environment
|
77
|
+
|
78
|
+
ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-darwin16]
|
79
|
+
GC Disabled: true
|
80
|
+
|
81
|
+
### Test Cases
|
82
|
+
|
83
|
+
#### nil
|
84
|
+
|
85
|
+
```
|
86
|
+
Warming up --------------------------------------
|
87
|
+
!! 320.852k i/100ms
|
88
|
+
!nil? 313.833k i/100ms
|
89
|
+
nil != 330.298k i/100ms
|
90
|
+
present? 294.813k i/100ms
|
91
|
+
Calculating -------------------------------------
|
92
|
+
!! 41.841M (± 0.6%) i/s - 207.591M in 5.000435s
|
93
|
+
!nil? 30.851M (± 0.7%) i/s - 153.464M in 5.005301s
|
94
|
+
nil != 38.424M (± 0.5%) i/s - 191.573M in 5.007580s
|
95
|
+
present? 19.660M (± 0.7%) i/s - 97.878M in 4.999761s
|
96
|
+
with 95.0% confidence
|
97
|
+
|
98
|
+
Comparison:
|
99
|
+
!!: 41841263.8 i/s
|
100
|
+
nil !=: 38424408.4 i/s - 1.09x (± 0.01) slower
|
101
|
+
!nil?: 30850983.5 i/s - 1.36x (± 0.01) slower
|
102
|
+
present?: 19660459.4 i/s - 2.13x (± 0.02) slower
|
103
|
+
with 95.0% confidence
|
104
|
+
```
|
105
|
+
|
106
|
+
#### []
|
107
|
+
|
108
|
+
```
|
109
|
+
Warming up --------------------------------------
|
110
|
+
!! 317.562k i/100ms
|
111
|
+
!nil? 311.181k i/100ms
|
112
|
+
nil != 319.266k i/100ms
|
113
|
+
present? 293.159k i/100ms
|
114
|
+
Calculating -------------------------------------
|
115
|
+
!! 42.487M (± 0.6%) i/s - 211.179M in 5.005333s
|
116
|
+
!nil? 31.078M (± 0.5%) i/s - 154.968M in 5.005557s
|
117
|
+
nil != 38.313M (± 0.6%) i/s - 190.283M in 5.000799s
|
118
|
+
present? 21.854M (± 0.7%) i/s - 108.762M in 5.002198s
|
119
|
+
with 95.0% confidence
|
120
|
+
|
121
|
+
Comparison:
|
122
|
+
!!: 42487427.1 i/s
|
123
|
+
nil !=: 38312618.0 i/s - 1.11x (± 0.01) slower
|
124
|
+
!nil?: 31078123.9 i/s - 1.37x (± 0.01) slower
|
125
|
+
present?: 21854143.8 i/s - 1.94x (± 0.02) slower
|
126
|
+
with 95.0% confidence
|
127
|
+
```
|
128
|
+
|
129
|
+
#### #<Object:0x00007f9c0a968310>
|
130
|
+
|
131
|
+
```
|
132
|
+
Warming up --------------------------------------
|
133
|
+
!! 328.432k i/100ms
|
134
|
+
!nil? 307.084k i/100ms
|
135
|
+
nil != 324.749k i/100ms
|
136
|
+
present? 261.758k i/100ms
|
137
|
+
Calculating -------------------------------------
|
138
|
+
!! 40.897M (± 0.5%) i/s - 203.628M in 5.005426s
|
139
|
+
!nil? 30.242M (± 0.6%) i/s - 150.471M in 5.000563s
|
140
|
+
nil != 39.610M (± 0.6%) i/s - 197.123M in 5.005610s
|
141
|
+
present? 12.163M (± 0.8%) i/s - 60.728M in 5.011771s
|
142
|
+
with 95.0% confidence
|
143
|
+
|
144
|
+
Comparison:
|
145
|
+
!!: 40897495.2 i/s
|
146
|
+
nil !=: 39610078.3 i/s - 1.03x (± 0.01) slower
|
147
|
+
!nil?: 30242403.1 i/s - 1.35x (± 0.01) slower
|
148
|
+
present?: 12162705.7 i/s - 3.36x (± 0.03) slower
|
149
|
+
with 95.0% confidence
|
150
|
+
```
|
151
|
+
|
152
|
+
#### Empty array `nil` comparison
|
153
|
+
|
154
|
+
```
|
155
|
+
Warming up --------------------------------------
|
156
|
+
!= nil 326.024k i/100ms
|
157
|
+
nil != 270.805k i/100ms
|
158
|
+
Calculating -------------------------------------
|
159
|
+
!= nil 40.133M (± 0.5%) i/s - 199.853M in 5.004102s
|
160
|
+
nil != 11.551M (± 0.9%) i/s - 57.681M in 5.020992s
|
161
|
+
with 95.0% confidence
|
162
|
+
|
163
|
+
Comparison:
|
164
|
+
!= nil: 40133046.7 i/s
|
165
|
+
nil !=: 11551012.8 i/s - 3.47x (± 0.04) slower
|
166
|
+
with 95.0% confidence
|
167
|
+
```
|
@@ -0,0 +1,75 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Run from the command line: bundle exec ruby benchmarks/empty_literal.rb
|
4
|
+
require_relative 'bm_setup'
|
5
|
+
|
6
|
+
display_benchmark_header
|
7
|
+
|
8
|
+
# rubocop:disable Style/EmptyLiteral
|
9
|
+
section "[] vs Array.new" do |bench|
|
10
|
+
bench.report("Array.new") do
|
11
|
+
Array.new
|
12
|
+
nil
|
13
|
+
end
|
14
|
+
|
15
|
+
bench.report("[]") do
|
16
|
+
[]
|
17
|
+
nil
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
section "{} vs Hash.new" do |bench|
|
22
|
+
bench.report("Hash.new") do
|
23
|
+
Hash.new
|
24
|
+
nil
|
25
|
+
end
|
26
|
+
|
27
|
+
bench.report("{}") do
|
28
|
+
{}
|
29
|
+
nil
|
30
|
+
end
|
31
|
+
end
|
32
|
+
# rubocop:enable Style/EmptyLiteral
|
33
|
+
|
34
|
+
__END__
|
35
|
+
|
36
|
+
### Environment
|
37
|
+
|
38
|
+
ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-darwin16]
|
39
|
+
GC Disabled: false
|
40
|
+
|
41
|
+
### Test Cases
|
42
|
+
|
43
|
+
#### [] vs Array.new
|
44
|
+
|
45
|
+
```
|
46
|
+
Warming up --------------------------------------
|
47
|
+
Array.new 238.371k i/100ms
|
48
|
+
[] 336.249k i/100ms
|
49
|
+
Calculating -------------------------------------
|
50
|
+
Array.new 6.298M (± 1.0%) i/s - 31.465M in 5.014660s
|
51
|
+
[] 14.157M (± 0.8%) i/s - 70.612M in 5.004166s
|
52
|
+
with 95.0% confidence
|
53
|
+
|
54
|
+
Comparison:
|
55
|
+
[]: 14157286.9 i/s
|
56
|
+
Array.new: 6297668.8 i/s - 2.25x (± 0.03) slower
|
57
|
+
with 95.0% confidence
|
58
|
+
```
|
59
|
+
|
60
|
+
#### {} vs Hash.new
|
61
|
+
|
62
|
+
```
|
63
|
+
Warming up --------------------------------------
|
64
|
+
Hash.new 140.548k i/100ms
|
65
|
+
{} 348.340k i/100ms
|
66
|
+
Calculating -------------------------------------
|
67
|
+
Hash.new 2.203M (± 1.1%) i/s - 11.103M in 5.056212s
|
68
|
+
{} 14.285M (± 0.6%) i/s - 71.410M in 5.010915s
|
69
|
+
with 95.0% confidence
|
70
|
+
|
71
|
+
Comparison:
|
72
|
+
{}: 14285184.2 i/s
|
73
|
+
Hash.new: 2202622.4 i/s - 6.49x (± 0.08) slower
|
74
|
+
with 95.0% confidence
|
75
|
+
```
|
@@ -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
|
+
```
|