From: Robert Klemme Date: 2010-10-16T18:50:19+09:00 Subject: Re: Process for optimizing ruby code On 16.10.2010 00:02, Ryan Davis wrote: > > On Oct 15, 2010, at 06:20 , Andrew Wagner wrote: > >> 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. > > The biggie for me is to look at the values in the % column and see > what the curve is like: > > (contrived) > > % time call 36% w 10% x 5% y 1% z > > vs: > > % time call 5% w 4% x 3% y 1% z > > In the first example, you have something more akin to a power law > curve. That says that a majority of the time is being spent in a > minority of the calls and is a good candidate for optimizing. You > then need to look and see if it is the number of calls that is > causing it (which would mean it is a good candidate for memoization > or some other form of caching) or if it is from accessing external > resources that block or... something. Very good advice IMHO! > In the second example, while the times of the profile might be high, > the % of time spent is not... graphing that is pretty flat... it is > relatively linear with a fairly flat slope. Something seems to be missing here. What would be your recommendation in this case? I'd say, tuning is more difficult in this case since you might have to consider architectural changes that affect multiple components. In any case chances are that tuning is more costly than in the first case. Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/