Re: Good Use of GOTO

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

c.k.lester wrote:
> 
> 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.
> 

I ran it a few times.

[jeremy@jdesk 40goto]$ time exu floop.e 

real    0m1.162s
user    0m1.163s
sys     0m0.000s
[jeremy@jdesk 40goto]$ time exu floop.e 

real    0m1.155s
user    0m1.153s
sys     0m0.000s
[jeremy@jdesk 40goto]$ time exu floop.e 

real    0m1.198s
user    0m1.197s
sys     0m0.000s
[jeremy@jdesk 40goto]$ time exu floop.e 

real    0m1.157s
user    0m1.157s
sys     0m0.000s
[jeremy@jdesk 40goto]$ time exu floop.e 

real    0m1.156s
user    0m1.150s
sys     0m0.003s

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

Quad 4 2.4GHz grin

--
Jeremy Cowgar
http://jeremy.cowgar.com

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

Search



Quick Links

User menu

Not signed in.

Misc Menu