0

I wonder what the benchmark for few rails methods would look like. Anyone got a website that can run custom methods?:

User.count
#=> 1000000 (Let's say about that)

u = User.where(account_id: 5)
u.count
#=> 100000

u.map |a| a.account_id = 6 end

Is there a way to test this sort of benchmark? How slow or fast is that iteration?

Sylar
  • 8,631
  • 20
  • 72
  • 139

1 Answers1

0

You can use ruby benchmark module for this kind of test

require 'benchmark'
Benchmark.bm do |x|
  x.report { User.count }
  x.report { u = User.where(account_id: 5); u.count }
  x.report { u = User.where(account_id: 5); u.map |a| a.account_id = 6 end }
end
sadaf2605
  • 6,634
  • 8
  • 49
  • 87