Marc Heiler wrote:
> Anyone of you has a few hints on how to speed up ruby code?
> (Note - not writing it, but running it ;-) )
> 
> I only have a few hints, like 5... would love to extend it.
> 
> So without further ado:
> 
> - Using << instead of += for Strings as += creates a new object
> whereas << will simply work on the current object.
> 
> - Use Inline C for critical methods (had to include that ;> )
> 
> - Reusing variable names might be better than using a lot of
> different variables
> 
> -  for is faster than .each on Arrays
> 
> - .last is faster than [0]
> 
> - .zero? is faster than == 0
> 
> 
> If you know a few more hints, please add!

http://www.informit.com/store/product.aspx?isbn=0321540034

A whole book full of tips!