A Complete Guide to Using RubyInline for Optimization
Eric Hodel has put together a great guide to optimizing Ruby code with RubyInline and ruby-prof, a code profiler.
Here's how I optimized png.rb to make PNG saving over 100 times faster using RubyInline. This is a good model to follow to make any ruby program faster.
The basic steps are to optimizing code are:
2. Find the method taking the most time
3. Try one change to make it faster
5. Check for improvement
* No improvement? Not enough improvement? Remove your change, go to step 3
* Improvement? Go to step 1