Skip to content

Instantly share code, notes, and snippets.

@ChuckJHardy
Created July 1, 2014 13:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ChuckJHardy/94fee0705e7820ecef75 to your computer and use it in GitHub Desktop.
Save ChuckJHardy/94fee0705e7820ecef75 to your computer and use it in GitHub Desktop.
BootTime

Fixing the Load Times

I noticed the boot time for the application was very slow. Here are the actions and steps I took to decrease it.

Benchmark Requires

The first think I needed to do was benchmark how long each bit of code took to be required by the application. I used a script I found on Google to help.

Combining and adding all the require times together you can see that it take almost a minute to load everything.

$ ruby AddTimes_0.rb
57.22181100000005

$ vagrant ssh -c "cd /vagrant; time rails console"
real	0m46.279s
user	0m5.752s
sys	    0m3.324s

$ vagrant ssh -c "cd /vagrant; time rspec spec"

# Number of Requires
654

Actions to Reduce Boot Time

** Remove requires out of application.rb **

Commit SHA:

$ ruby AddTimes_1.rb
2.870594000000001

$ vagrant ssh -c "cd /vagrant; time rails console"
real    0m25.483s
user    0m6.724s
sys     0m2.220s

$ vagrant ssh -c "cd /vagrant; time rspec spec"

# Number of Requires
311
@mfilej
Copy link

mfilej commented Jul 2, 2014

I love you Chuck!

@lminaudier
Copy link

❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment