Zack Hubert

Watches Benchmark: A Ruby Gem for Avoiding Performance Regressions

I have a pretty normal workflow…I work on something and then move on to something else. While I always strive to minimize coupling, it’s inevitable that sometimes those new things I work on effect the old. Having good test coverage running under continuous integration catch the situations where I’ve literally broken functionality, but what about the times when I’ve simply made that old thing sluggish?

While there are all sorts of heavyweight tools for performance analysis, they mostly rely on me looking at them (a fatal flaw when what I want to look at is the new code I’m writing). Of course, I watch production performance like a hawk, but I’d love to avoid the mad scramble to patch production due to an unforeseen performance regression. What would be great would be an exception driven notification that radiates the information to me, rather than me having to dig through graphs to find it…in development when I’m making the mistakes.

So, I made a super simple gem for the development environment that helps me keep my performance promises. When I’m building new functionality where performance is a sensitive issue, I simply assign that method an SLA and the simple gem watches_benchmark will tell me via Logger and Growl when I’ve made a change that has broken the SLA. Then I have causality to the performance regression and can fix it right away.

It’s pretty rough cut and an imperfect solution (development environments have a tendency for variability), but I find that it has been helping me on my current project.

Comments