From: Robert Klemme Date: 2010-10-15T23:54:58+09:00 Subject: Re: Process for optimizing ruby code On Fri, Oct 15, 2010 at 3:20 PM, Andrew Wagner wrote: > So, I've got a chunk of code which needs optimizing. Yes, it really needs > it, I'm not optimizing prematurely. It (mostly) works, it's just way too > slow. And I knew it would be too slow when I wrote it, I just wanted to come > up with a simple implementation first, and get it under test. > > That said, I'm wondering if there are any suggestions out there for > tutorials on using ruby-prof. Not tutorials like "here are what the numbers > mean", but "here are some suggestions for looking at the numbers and > deciding where you'll get the most gain in optimizing. That's the usual approach when tuning: take the slowest part, make it faster. Repeat until performance is sufficient - or you run out of money. A generally candidates for optimization is object allocation. That is slow compared to other operations because of the GC management involved. Also, if you do lookups in huge Array you might want to switch to indexed access via Hash. Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/