On Oct 7, 12:45=A0pm, Rick DeNatale <rick.denat... / gmail.com> wrote:
> On Thu, Oct 7, 2010 at 12:05 PM, Jeremy Bopp <jer... / bopp.net> wrote:
> > The point of comparison profiling like this is to find ways to improve
> > your code without changing its ultimate function. =A0Your comparison he=
re
> > compares two fundamentally different operations
>
> It struck me as odd that Trans is benchmarking two different things
> against each other.
>
> As another example, =A0I just benchmarked the time it takes me to get up
> out of my sofa and walk to my front door and back at about 30 seconds.
> =A0That's over 3 times FASTER than Fernando Alonso's fastest lap of
> 1:47.976 in the Singapore Grand Prix a couple of Sunday's ago.
>
> So does that make me faster than a Ferrari F10, I don't think so, and
> I doubt that it has a practical significance.

I think this is a good a reminder as any that it's hard to see what
someone else is getting at when you're not seeing the use case. There
is in fact a very good reason for my comparison. I often do:

  class X
    def f
      @f ||=3D ( do_some_calc_or_lookup )
    end
  end

I like this idiom as it provides the speed bump of caching and yet
encapsulates the entire procedure for getting the value in one place.
However, if I am really concerned about squeezing out every bit of
speed, I would do:

  class X
    def initialize
      @f =3D ( do_some_calc_or_lookup )
    end
    def f
      @f
    end
  end

The purpose of the benchmark was to see just how much "squeeze" I am
getting in the exchange.