From: Su Zhang Date: 2012-02-03T11:40:24+09:00 Subject: Re: Basic Ruby performance On 2/2/2012 9:14 PM, Dmitry Nikiforov wrote: > My main area of development is processing of rather large amounts of > data (billions of entries, primarily processed by regular expressions, > with some statistical analysis on top, and potentially - addition of NLP > later). You _have_ to iterate through every entry of the incoming data > (which might already be in the database, plain text file, or might be > just a "fire hose" of data pouring into the system in real time). > > While I'd LOVE to have a nice and clean syntax, performance is still > number 1 on my list of priorities, therefore I asked if maybe there are > ways to improve Ruby performance. > One thing you can do is to replace for loops with while loops. For loops in Ruby will be translated to method calls to Enumerable#each, and in Ruby 1.9, Enumerable#each is slower than using ordinary while loops because of the overhead of processing enumerators. It is actually even slower than Ruby 1.8's Enumerable#each because 1.8 does not have enumerators.