Performance: is_a? vs grep

The only definitive answer is to profile your code in the context of what you are trying to do.

There is an old thread on SketchUcation on the topic of performance optimisations; Optimization Tips • sketchUcation • 1.

One of the finding there was that for in loops was faster than .each (in general). But that held true for Ruby 1.8. In Ruby 2.0 and onwards that changed.

And there are many other subtle behaviours that could affect how fast your loop will be. So; profile, profile, profile.