Skip to content

Instantly share code, notes, and snippets.

View ryz310's full-sized avatar
😁
Fine

Ryosuke Sato ryz310

😁
Fine
View GitHub Profile
@ryz310
ryz310 / test_merges.rb
Last active July 21, 2021 08:11 — forked from kelan/test_merges.rb
Test ruby hash merging speed (#merge vs #merge!).
#!/usr/bin/env ruby
# To test is using `defaults.merge(options)` or `defaults.merge!(options)`
# is faster, I ran the following:
Benchmark.bm(7) do |x|
x.report("#merge:") do
10000000.times do
defaults = {:a => 1, :b => 2, :c => 3, :d => 4}
options = {:a => "another value", :d => true}