Understanding Ruby on Rails render times

怎甘沉沦 提交于 2019-12-05 01:39:13
Jordan Brough

This:

Rendered user/_old_log (25.7ms)

is the time to render just the _old_log partial template, and comes from an ActiveSupport::Notification getting processed by ActionView::LogSubscriber

This:

Completed 200 OK in 466ms

Is the http status returned, as well as the total time for the entire request. It comes from ActionController::LogSubscriber.

Also, note those parenthetical items at the end:

(Views: 124.6ms | ActiveRecord: 10.8ms)

Those are the total times for rendering the entire view (partials & everything) and all database requests, respectively, and come from ActionController::LogSubscriber as well.

Jordan's answer is correct. To paraphrase, the first number is the time the page took to load. The second is how long the view took to generate. The last number is how long it took for your database to handle all queries you sent to it.

You can also get an estimation of how long your Controller and Model code took by subtracting the last two numbers from the first number, but a better way would be to use the Benchmark.measure method (http://www.ruby-doc.org/stdlib/libdoc/benchmark/rdoc/classes/Benchmark.html).

Your new way appears to have improved because code in the Controller/Model completes faster.

Your new way is spending less time overall but more time rendering the template.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!