开发者

How can I tell what is taking my request so long?

开发者 https://www.devze.com 2023-03-10 06:42 出处:网络
So here\'s the final line of my request: Completed in 9209ms (View: 358, DB: 1582) So I need to figure out what\'s holding up the request.This request can get to be upwards of a minute, so I really

So here's the final line of my request:

Completed in 9209ms (View: 358, DB: 1582)

So I need to figure out what's holding up the request. This request can get to be upwards of a minute, so I really need to figure this one out. If the DB and View take 1.9 seconds, then tha开发者_运维知识库t means there's 7.2 seconds that are unaccounted for in the log. How can I further analyze other parts of the code? It would be great to know if, say, there was a single callback that's largely responsible for the delay.


Generally code that isn't in the DB or the view is in the controller (or it could be in the logic part of the model). The biggest culprits I've had problems with are loops within loops, or gratuitous use of :include => {...stuff...}


Are you materializing a lot of records from the database? Query time might not be much, but if, say, I selected 10,000 records from the database using a very simple and fast query, I'd still expect my page load time to be high, since it would spend a considerable amount of time hydrating the large recordset.

I'd suggest running some profiling tests (rake test:profile). These should give you an indication of where most of the time is being spent. You'll probably find it's just one or two method calls that are being invoked with excessive frequency.

0

精彩评论

暂无评论...
验证码 换一张
取 消