Re: Good Use of GOTO
- Posted by Matt Lewis <matthewwalkerlewis at gmail??om> Jun 06, 2008
- 816 views
c.k.lester wrote: > > Jeremy Cowgar wrote: > > c.k.lester wrote: > > > How does this compare: > > > function factorial_fast(atom a) > > > end function > > > I show similar improvement vs factorial() without the use of GOTO. > > > > > > > I ran it a few times. > > So, my factorial_fast() runs in about 1.57s over one million > iterations. GOTO runs in about 1.42s for one million iterations. > So, the GOTO is about 10% faster, right? In this case, I would > use whatever version was in the standard lib. I personally don't have > code that iterates one million times, so it wouldn't matter. > However, 10% improvement is excellent. Alas, a difference of 0.15 > seconds is not likely to be noticed by your casual human observer. I will just say that I've had code that has had to run many many millions of iterations. These are basically custom optimization problems (i.e., find the combination such that the objective function is minimized) that don't easily fit into standard linear/integer programming solutions. This stuff takes hours to run, and costs money. So any improvement is a good thing. And they already had inline asm for some of the really critical bit twiddling stuff to optimize. Matt