On Tue, 14 Mar 2006 05:18:33 +0900, Charles O Nutter <headius / headius.com>
wrote:

[snip] 
> Someone wanna run a comparison of performance between the two? If
> continuations were fast enough, I'd expect it to be faster, but I've heard
> they're not as fast as we'd like in Ruby.

I just ran a simple test using this function:

  def foo(n)
    if n == 0
      return n
    else
      return foo(n-1)
    end
  end

(I didn't use factorial or fibonacci because I didn't want the timings to
be swamped by the costs of large Bignums when n is 1,000,000).

Timings for n = [10000, 100000, 1000000] put the throw/catch version at
approximately a factor of 1.6(ish) faster than the continuation based
version. (the throw/catch version is from ruby-talk:145593 as Pit pointed
out above).

regards,
andrew