Skip to content

Commit ace9cba

Browse files
committed
add-benchmark
1 parent 6d3cd7e commit ace9cba

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

benchmark.rb

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
require 'benchmark'
2+
3+
STRING_HASH = { 'foo' => 'bar'}
4+
SYMBOL_HASH = { :foo => 'bar'}
5+
NUMBER_HASH = { 100 => 'bar'}
6+
str,sym,num = 'foo', :foo, 100
7+
8+
n = 100_000_000
9+
Benchmark.bmbm do |x|
10+
x.report('String') { n.times { STRING_HASH[str] } }
11+
x.report('Symbol') { n.times { SYMBOL_HASH[sym] } }
12+
x.report('Number') { n.times { NUMBER_HASH[num] } }
13+
end

0 commit comments

Comments
 (0)