Re: simple eurphoria question

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

Chris Bensler wrote:
> 
> Ricardo M. Forno wrote:
> > Yep, you are right.
> > I performed the following test of candidate good functions for this task.
> > The results showed all three were correct, but f2 was the fastest:
> 
> Did you try changing the order of the code in your bench tests, to verify that
> it wasn't affecting your results? I've found it to be a major factor in any
> kind of trivial timing test.
> 
> Also, it should be slightly faster if the last return statement in f2() was
> inside of an if-branch..
> As Matt (I beleive) pointed out with his winning code from the christmas
> contest
> a few years ago.
> 
> }}}
<eucode>
> function f2(atom a)
>   if a < 0 then
>     return - floor(- a)
>   else
>     return floor(a)
>   end if
> end function
> </eucode>
{{{

> 
> Chris Bensler
> ~ The difference between ordinary and extraordinary is that little extra ~
> <a href="http://empire.iwireweb.com">http://empire.iwireweb.com</a> - Empire
> for Euphoria

Hi Chris.
I tested both versions before posting this mail,
with the return inside the if and outside it.
Both had identical timings.

Regarding the code order, what change would you suggest?
Regards.

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

Search



Quick Links

User menu

Not signed in.

Misc Menu