Back to Resources

Blog

Posted February 26, 2013

Break Things Faster with Ruby Parallelization

quote

You're probably wasting two things when you're testing. Your time... because the other thing is your extra CPUs. Any time you're waiting on a relatively slow resource, your CPU is just sitting there, twiddling its silicon thumbs. If you're only using one CPU core at a time, the other cores are doing much the same. Unfortunately for web developers who do things involving CRUD operations, slow resources includes databases. Most unfortunately for you, Dear Reader (and us, Dear... Us), they also include the browsers you're integrating with for Selenium testing.

One of the best ways to get more test for your tokens is to run more tests at once. If you've got several tests going, even if some are waiting for one slow resource, the others can use the CPU. The more tests you can run at once, the shorter your test cycles will be, especially if you could, say, spin up more then one copy of the slow resource to test with (Psst: I'm talking about Sauce Labs Parallelization). I've been looking for ways to make parallelization easier when testing with Ruby, and I stumbled across the Parallel Tests gem. It's actively developed, has some nice documentation and integrates with rspec, rspec-rails and test:unit. Their benchmarks show that using the gem, the Rails ActionPack test suite time was cut in half, from 88 seconds to 44, with just 4 test runners. This, conveniently, is the number of parallel tests you can run with a Mild plan.

So for many of you, there's already a possibility of making your tests take half the time. Which means you can run twice as many. Which means a much faster turnaround time for TDD, BDD, and release testing. I'd say that's a win.

Published:
Feb 26, 2013
Share this post
Copy Share Link
© 2023 Sauce Labs Inc., all rights reserved. SAUCE and SAUCE LABS are registered trademarks owned by Sauce Labs Inc. in the United States, EU, and may be registered in other jurisdictions.