Skip to content

Instantly share code, notes, and snippets.

@chiting
Created October 5, 2015 15:21
Show Gist options
  • Save chiting/3bad0816fd7986d901e9 to your computer and use it in GitHub Desktop.
Save chiting/3bad0816fd7986d901e9 to your computer and use it in GitHub Desktop.
require 'benchmark/ips'
def slow
Array.new
end
def fast
[]
end
Benchmark.ips do |x|
x.report('Array.new') { slow }
x.report('Array[]') { fast }
x.compare!
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment