Simple problem, I have a legacy Rails 2.3 application and it takes quite long to do anything. rake
takes over 25 seconds, but it doesn't look like anything is really happening.
Is there any simple way I can just get some kind of profiler dump from the time when the app is loading, to see which methods take the longest time?
A solution for both Rails 2.3 and 3.1 would be even more helpful.
A Rails application is usually started by running bin/rails console or bin/rails server .
An initializer is any file of ruby code stored under /config/initializers in your application. You can use initializers to hold configuration settings that should be made after all of the frameworks and plugins are loaded.
Go to your browser and open http://localhost:3000, you will see a basic Rails app running. You can also use the alias "s" to start the server: bin/rails s . The server can be run on a different port using the -p option. The default development environment can be changed using -e .
The problem could be that webpacker isn't stalled or your system can not locate it. So installing webpacker can be your next step. Try running this command in your terminal. After running the command navigate to your rails application and run the rails server command.
Profile a rake task that requires the rails environment, something like this:
desc "Load it"
task :loadit => :environment do
end
then profile with ruby-prof
ruby -Ilib -S ruby-prof -p graph_html `which rake` loadit > profile.html
It ought to work with rails 2.3 have only tested it on 3.x but I see no reason why it should not work.
You could start your application with a profiler hooked in, e.g. ruby-prof or perftools.rb. While it's still starting up, launch a HTTP query against it, which would try go GET
a /kill_me
route as soon as the application starts. /kill_me
could cause your application to gracefully die by calling exit
. As a result you've got a profile of your startup.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With