Re: Good Use of GOTO

new topic     » goto parent     » topic index » view thread      » older message » newer message

Jeremy Cowgar wrote:
> 
> Ok, here are the benchmarks you asked for CK...

Jeremy, thanks for those benchmarks!

How does this compare:

function factorial_fast(atom a)
atom b
  b = a
  a -= 1
  while a > 1 do
     b = b * a
     a -= 1
  end while
  return b
end function

I show similar improvement vs factorial() without the use of GOTO.

(You must be on a beast of a PC... I get 5.422 and 2.531 for factorial()
and factorial_fast().)

> Now, bear in mind, this is an optimization. The non-goto version of factorial
> is much simpler, but also much slower. You would only resort to a situation
> like this if you have measured speed and speed was not acceptable for your
> situation.

I consider all my apps to be time critical. Well, 90% of them. :) But that's
the speedfreak in me.

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu