Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Ruby DeRailed Pt 1: Fast Tests

Myles Megyesi
September 27, 2013

Ruby DeRailed Pt 1: Fast Tests

In this talk I analyze what in the Rails environment that causes slow tests and what we can do to fix it.

Myles Megyesi

September 27, 2013
Tweet

More Decks by Myles Megyesi

Other Decks in Technology

Transcript

  1. Controllers Views Models Business Logic Controllers Views Models Business Logic

    Omakase Rails App Extraction Friday, September 27, 13
  2. User-Facing App Controllers Views Controllers Views Admin App Shared Gem

    Models Business Logic Business Logic Friday, September 27, 13
  3. User-Facing App Views Controllers Admin App Shared Gem Presentation Logic

    App Specific Use Cases Views Controllers Presentation Logic App Specific Use Cases Generic Use Cases Business Logic Models Friday, September 27, 13
  4. 2 Lessons Learned • Extraction is not enough • Don’t

    depend on external services Friday, September 27, 13
  5. Rails “environment” • Load the Rails framework • Load all

    dependencies in the Gemfile • initialize! ★ Load all code in Rails Engines Friday, September 27, 13
  6. 0 1.5 3 4.5 6 9 13 20 25 39

    53 Empty Rails App Friday, September 27, 13
  7. 0 100 200 300 400 Attempt #1 Attempt #2 Attempt

    #2 Projected Total Test Suite Time Attempt #1: 4853 examples, 377.13 seconds Attempt #2: 1706 examples, 7.19 seconds Attempt #2: Projected to 4853 examples, 20.45 seconds Friday, September 27, 13
  8. Time to Run One Test Attempt #1: 18.195 seconds, 69

    gems Attempt #2: 1.580 seconds, 40 gems 0 5 10 15 20 Attempt #1 Attempt #2 Friday, September 27, 13
  9. 0 1.5 3 4.5 6 10 13 20 25 40

    53 Attempt #2 Empty Rails App Friday, September 27, 13