Created
March 30, 2015 12:38
-
-
Save sergey-alekseev/8a0b8421e5b7adcd2482 to your computer and use it in GitHub Desktop.
Ruby Merge vs. Merge! comparison (benchmarking)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Benchmark.ips do |x| | |
x.report('merge') { {}.merge :a => 1 } | |
x.report('merge!') { {}.merge! :a => 1 } | |
x.compare! | |
end | |
Calculating ------------------------------------- | |
merge 34.220k i/100ms | |
merge! 33.039k i/100ms | |
------------------------------------------------- | |
merge 1.923M (±32.2%) i/s - 7.631M | |
merge! 2.582M (±34.2%) i/s - 6.740M | |
Comparison: | |
merge!: 2582064.1 i/s | |
merge: 1922744.2 i/s - 1.34x slower |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment