Rails benchmark the filter chain?
I'm doing some optimisation on my Rails (2.3.5) app, and can't seem to find an elegant way of benchmarking the filter chain. I'm ab testing the site with something like:
ab -n 200 -c 3 -i -k http://localtestingserver:80/test
/test is setup with nothing in the controller and nothing in the page, so it's just loading our default filter chain plus rendering the layout. I get an average of 86ms per request, fine.
When I disable the fi开发者_JAVA技巧lters (skip_filter filter_chain) it drops to 37ms, and without the layout (render :layout => false) it drops to 16ms. Is there a way I can benchmark, perhaps with Benchmark.realtime, each function being loaded in the filter chain, before the controller is called (or indeed after)? Can I output even a list of all filters being called on a request?
Thanks,
Dan
Edit
I'm using the Hodel3000 logger and Oink so get output per request like:
Jan 27 17:56:55 testing rails[19611]: Memory usage: 98748 | PID: 19611
Jan 27 17:56:55 testing rails[19611]: Instantiation Breakdown: Total: 2 | Room: 1 | User: 1
Jan 27 17:56:55 testing rails[19611]: Completed in 240ms (View: 28, DB: 0) | 200 OK [/test]
I'd just like to better understand and profile what happens before the controller is called - I can profile the controllers themselves fine. Like where the extra 212ms is from in the above request. Obviously I could drop code into each of my own before_filters, but hoped there was a way to wrap every filter in one go (like ones from included gems, etc.).
The Performance Testing Rails Applications guide looks like a good place to start.
精彩评论