June 10th, 2008 By: Daniel
Recently I was trying to optimize my code a little and needed a quick way to compare the speed of different code snippets. Of course Rails comes with the Benchmark module for doing just that. It is, however, in my opinion a bit clunky for quick tests. Look at all the typing it takes just to find the average speed of a snippet over 100 iterations:
So I tossed this into my ~/.irbrc file:
And now I can “time it” like this:
Much nicer!
No comments:
Post a Comment