Created
May 10, 2013 17:16
Friday Dev Discussion, May 10 201
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Agenda | |
Overview | |
* be sure to think of something you learned this week that you'd like to | |
share | |
* Discuss three gems: | |
## bullet (https://github.com/flyerhzm/bullet) | |
# Gemfile | |
gem 'bullet' | |
bundle install | |
# config/environments/development.rb | |
config.after_initialize do | |
Bullet.enable = true | |
Bullet.alert = true | |
Bullet.bullet_logger = true | |
Bullet.console = true | |
Bullet.rails_logger = true | |
end | |
1. Edit app/controllers/admin/users_controller.rb:19 | |
remove: User.includes(:merchant) | |
2. Go to http://localhost:5000/admin/users | |
3. Check console to see N+1 query output | |
4. If you want to tell what the speed-up is, you need to profile it over a | |
bunch of requests (to eliminate caching variability) | |
5. Lastly, there are some instances where keeping the N+1 is preferable. On | |
admin/bundles, you'll find there is one between bundle and user. Adding it | |
back in, however, has the side-effect of making the page *much* slower. | |
Check it out for yourself if you want to see it. | |
## pry (http://pryrepl.org) | |
1. gem install pry | |
2. Basic stuff: | |
cd CodeGenerator | |
ls | |
$ (or show-source) | |
c = CodeGenerator.new | |
c.gen<tab> | |
wtf? | |
show-source CodeGenerator#generate | |
c.generate 52 | |
3. Debugging | |
binding.pry | |
st test/unit/order_test.rb -n "/equal total minus balance/" | |
nesting | |
play -l 235 | |
reload-code | |
# remove order.rb:234 | |
https://github.com/nixme/pry-nav | |
- adds simple debugging features (step, next, continue) | |
## spring (https://github.com/jonleighton/spring) | |
1. gem install spring (not needed in the Gemfile) | |
psgrep spring | |
2. Aliases: | |
alias st='spring testunit' | |
alias srdm='spring rake db:migrate' | |
alias srtps='spring rake test:parallel_with_specs' | |
3. Compare: | |
time t test/unit/ticket_test.rb | |
time st test/unit/ticket_test.rb | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment