如何准确基准化模型加载所需的时间?

如何准确基准化模型加载所需的时间?

问题描述:

我想确定加载模块所需的时间(find_by_id(234)调用).

I want to benchmark the time it takes to load a module (a find_by_id(234) call).

此外,我如何跟踪加载页面所需的时间,我知道我在运行Rails Server时获得了此信息,但这是在调试模式下,我希望可以进行生产速度基准测试吗?

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.

一个例子是:

require "benchmark"

time = Benchmark.measure do
  a.find_by_id(234)
end
puts time

但是对于生产级别的基准测试,我会查看 New Relic.他们几乎为您提供了令人难以置信的基准测试的.

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