Skip to content

Instantly share code, notes, and snippets.

@ebouchut
Created October 30, 2014 15:24
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save ebouchut/da5846c1e92cedce3a02 to your computer and use it in GitHub Desktop.
Ruby Benchmark
require "benchmark"
array = [...]
Benchmark.bm(7) do |x|
x.report("map") { array.map(&:upcase) }
x.report("map!") { array.map!(&:upcase) }
end
#
# user system total real
# map 0.000000 0.000000 0.000000 ( 0.000014)
# map! 0.000000 0.000000 0.000000 ( 0.000012)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment