From: "Simon Kröger" Date: 2006-05-23T05:57:41+09:00 Subject: Re: Zed and Luis drop the bomb on Ruby's poor performance Sam Roberts wrote: > Quoting SimonKroeger@gmx.de, on Tue, May 23, 2006 at 05:12:14AM +0900: >> Hi Sam! > > Hi Simon, > >> Conclusion: method calls in general and object creation are the >> bottlenecks in this (very, very) simple cases. > > My conclusion as well. > > My real app basically runs over all the lines in a set of files using > IO#each, runs a regex, turns the matched strings into objects, so is > pretty much dominated by these simple cases (I think, and profile > suggests). > > Your !-optimizations are interesting. I'll look back at my low-level > code. Maybe by changing my "name = $2.upcase" statements to "name = $2; > name.upcase!" I can get some good speedups. Depends on whether I need to > keep both versions around, I'll have to construct some test cases and > profile them. > > Thanks, > Sam There were some performance tips posted here some time ago, keeping the number of objects low is definitely a good start. I just don't like the bang methods because you can't method-chain with them. (a lot of the return nil if there is no change) If the files aren't that big try to read them in one big read - should be way faster. Another one of the tips posted before was: use sqlite - and i can wholeheartedly support that. If you have the chance to change your data format to a sqlite database you can run a select on thousands of lines in virtually no time. (and it's really, really painless to use) cheers Simon