Skip to content

Instantly share code, notes, and snippets.

@logankoester
Created August 17, 2011 20:18
Show Gist options
  • Save logankoester/1152499 to your computer and use it in GitHub Desktop.
Save logankoester/1152499 to your computer and use it in GitHub Desktop.
Simple benchmarking for ActiveRecord Queries in rails console
# Give it two procs to compare
def bm(o, n); reload!; puts "Running 10 times"; Benchmark.bmbm(10) { |x| x.report('Old Query:') { @olr = o.call }; x.report('New Query:') { @nr = n.call } }; reload!; puts 'Old Result:' ; table(@olr); puts 'New Result'; table(@nr); end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment