Skip to content

DenisaSimon/performance-testing

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 

Repository files navigation

git clone git://github.com/ngauthier/performance-testing.git

Checkout the branch

git checkout origin/initial
cd sample-project
# you may need to gem install geminstaller
sudo geminstaller

Edit your database.yml to suit your machine.

Initialize the server

RAILS_ENV=development rake db:drop db:create db:schema:load db:stories
rm log/development.log
RAILS_ENV=development ruby script/server

Browse to page. Hit refresh a few times. Click on new and edit.

Check the server speed

slow-actions log/development.log --actions

And check the speed of the tests

rm log/test.log
RAILS_ENV=test rake db:drop db:create db:schema:load db:stories test
slow-actions log/test.log --actions

Got an email from a user: “lol ur site sux takes liek 5mins to load hahaha n00b”

Pull from production:

RAILS_ENV=development rake data:load
RAILS_ENV=development ruby script/server

Browse to index

# usually we would pull from the production log
slow-actions log/development.log --actions

OK, we have a problem with boxes/index. Time to write a profile test.

git checkout origin/profile_test

Look at the file “test/performance/boxes_index_test.rb”

# run, but it takes a long time, so I added the output to git
# ruby test/performance/boxes_index_test.rb

Open “tmp/performance/BoxesIndexTest#test_homepage_process_time_graph.html” in a browser Look at bold lines, scroll until a bold line is calling one of our processes

git checkout origin/benchmark_test

Look at the file “test/performance/boxes_rank_test.rb”

RAILS_ENV=test rake db:drop db:create db:schema:load db:stories
ruby test/performance/boxes_rank_test.rb
git checkout origin/fixed_code

Look at the file “app/models/box.rb”

Fix the code, and use the benchmark to ensure that it is faster.

About

A guide to performance testing in rails

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • HTML 97.4%
  • Ruby 2.5%
  • Other 0.1%