Created
January 24, 2015 22:33
-
-
Save yuki24/52ec30f96fbea33268da to your computer and use it in GitHub Desktop.
This file contains 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
require 'benchmark/ips' | |
Benchmark.ips do |x| | |
x.report "nothing" do | |
[1, 2, 3] | |
end | |
x.report "#-" do | |
[1, 2, 3] - [3] | |
end | |
x.report "#delete" do | |
[1, 2, 3].delete(3) | |
end | |
x.report "#delete + #tap" do | |
[1, 2, 3].tap{|ary| ary.delete(3) } | |
end | |
x.report "#delete + lvar" do | |
foo = [1, 2, 3] | |
foo.delete(3) | |
foo | |
end | |
x.compare! | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment