I want to benchmark the time it takes to load a module (a find_by_id(234) call).
Also, how can I track the time it takes to load a page, I know I get this information when I run rails server, but this is in debug mode, I want production speed benchmarks, possible?
For a quick check, I would highly recommend checking out Benchmark.
An example would be:
require "benchmark"
time = Benchmark.measure do
a.find_by_id(234)
end
puts time
However for production level benchmarking, I would check out New Relic. They offer unbelievable benchmarking on nearly everything you could think of.
They have a free developer mode here :
http://support.newrelic.com/kb/docs/developer-mode
You can use this gem: https://github.com/igorkasyanchuk/benchmark_methods
No more code like this:
t = Time.now
user.calculate_report
puts Time.now - t
Now you can do:
benchmark :calculate_report # in class
And just call your method
user.calculate_report
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With