Below are my notes from the second day at LSRC.
Faster Test Suites
Nick Gauthier gave an impressive talk on reducing the execution time of a test suite. The original suite took over 15 minutes to run. Using factory_girl, shoulda and paperclip, he strongly recommended empty DB testing (no fixtures, all tests setup and tear down their objects/records), and the use of “no side-effect” test blocks.
Switching to the use of fast_context the execution time was brought down to 5 minutes. Using perf_tools he found that calls to ImageMagic (from Paperclip) were calling out to the shell, taking a lot of time. So he mocked those calls and brought it down to 3 minutes.
Using Hydra to do multi-core (concurrent) testing he brought execution time down to 1 minute.
Hydra is easy to set-up (no sockets or daemons to configure). Just add a Rake task and configuration yml and you’re ready to use it.
When you run Test::Unit the Rails environment is loaded 4 times!! Cucumber loads the environment twice. RSpec and Hydra load it just once.
Further tweaking EXT4 journal_data_writeback and atime (access time) on the file system he got testing down to just 50 seconds. Using Ruby Enterprise Edition (with the tmalloc) and more tweaks (this time to the Ruby _HEAP and _GC settings) he had tests running in 18 seconds. A 4417% increase in performance!!
Check the comments below for a link to Nick’s presentation slides. He’s been kind enough to provide the link!
Searchability
Luigi Montanez gave an insightful presentation on SEO. He doesn’t believe that you have to be an “expert” in SEO. You simply need to have good content and Google (or Bing) will handle the rest. There are some things you can do though to make sure you don’t sabotage your pages when crawlers visit them.
Make sure you have a sitemap.xml (sitemaps.org) and a robots.txt (robotstxt.org). These help crawlers know what to pay attention to and what to ignore. Make sure you use either a www or non-www domain. If you have both choose one and redirect to it. You don’t want to have the site indexed under both.
When redirecting make sure you use 302 and 301 appropriately. 302 is for a temporary redirect, and Google/Bing will not index the page it’s redirected to. Use 301 instead, if your intention is to have the page permanently moved. Be cautious too because many web frameworks will use a 302 by default, instead of a 301.
Do not change your content by region, nor require cookies for someone to view content. Also page titles are very important. Always follow the “Page Title | Site Title” style (or you can replace | with a – or some other delimiter, just be consistent).
In your URLs dashes (-) are word separators, underscores (_) are not! Make sure you are using dashes in your URLs!! Take advantage of meta tagging, and Google Webmaster Tools.
Takeaway:
- Think like a searcher (search engine: crawler, index, rank)
- Optimize your title tags (they are the most important thing)
- Use Google Webmaster Tools (it provides valuable insight)
Components
Nick Sutterer gave a cool demonstration of Cells and Apotomo. They allow you to create stateful widgets in your Rails views.
Padrino
Joshua Hull gave a talk on Padrino, another web framework built on top of Sinatra. It takes a minimalist style approach (take what you need). It’s light-weight and fast. It has all the basic stuff you’d expect of web framework including a simple mailer.


You probably can use any Rails supported database, but I prefer Postgres. It’s a free database that is available on a variety of platforms (much like MySQL) but a little more powerful. I also find it easier to work with on JRuby so it’s the one I’ll use here.
