Skip to content

Instantly share code, notes, and snippets.

@knightq
Created February 27, 2013 15:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save knightq/5048731 to your computer and use it in GitHub Desktop.
Save knightq/5048731 to your computer and use it in GitHub Desktop.
Benchmarking Ruby
# Got from here: http://www.skorks.com/2010/03/timing-ruby-code-it-is-easy-with-benchmark/
require "benchmark"
Benchmark.bm(7) do |x|
x.report("first:") { (1..10000).each { |i| i } }
x.report("second:") { (1..10000).each { |i| i }}
x.report("third:") { (1..10000).each { |i| i }}
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment