问题
I need to profile the memory usage of a rails 4 application (using ruby MRI). A little bit of googling made me step into http://guides.rubyonrails.org/v3.2.13/performance_testing.html
I have two questions :
- Is it compatible with rails 4
- I am using rspec. It seems that my
rake test
tasts are not available (neitherrails generator performance_test
). When I typerake test:profile
for instance, I receiveDon't know how to build task 'test:profile'
. Does anybody know how to fix this ?
Thanks in advance for your help.
回答1:
Oink is something I use with Rails 4.
Oink adds memory and active record instantiation information to rails log during runtime and provides an executable to help digest the enhanced logs.
Given a minimum threshold and a metric (memory or active record instantiation), the oink executable reports:
The top ten single requests which exceeded the threshold for the metric, ordered by the request which exceeded the threshold the most
The number of times each action exceeded the threshold for the metric, ordered by the action which exceeded the threshold the most
(in verbose mode) The log lines produced by requests which exceeded the threshold
回答2:
I am not sure if it will work with MRI 2.1.0 but when I worked at Engine Yard will always recommended this tool:
Binary Logic's Memory Logic
One big warning about it though. It logs performance so you only want to do this in development or on a test server. Do not put it in to production or your application will grind to a halt. Hope this helps.
Mike Riley
来源:https://stackoverflow.com/questions/22101737/rails-4-memory-profiling