discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: AClock fork with republican time


From: Ingolf Jandt
Subject: Re: AClock fork with republican time
Date: Thu, 23 Nov 2006 13:22:42 +0100
User-agent: GNUMail (Version 1.2.0)

On 2006-11-22 23:26:20 +0100 Banlu Kemiyatorn <id@gamesquare.co.th> wrote:

Ingolf Jandt wrote:
Ah, Ok, Actually you are welcome to criticise my code, I was just kidding.
Once more: I did not want to criticise nor debate, only find out if there was something obvious I failed to see.

But now, for the sake of humor let's do this :)
Ok, for the bare fun of discussing...
... It looks to me that my method is faster...
I am absolutely not convinced. The amount of floating point instructions is about the same (yes, i have read the rest of the modf disassemble of my system). And a handful of MOVs on the stack are absolutely neglectible. 2. The code used sacrifices a lot of readability compared to "a/b", "modf (a/b,&dummy)" or even "a/b-floor(a/b)". Speed issues should only have precedence if there is no choice. 3. If speed did matter in any way the result would have been stored, not the computation code copied and pasted many times.

I put the code
    c=a-b*floor(a/b);c/=b;    or c=modf(a/b,&dummy);    or c=a/b;
    x=sin(2*M_PI*c);
    y=cos(2*M_PI*c);
into a loop and played with different inputs. It appears to me that
1. The calculation time of around 1,5(+-0,3)x10^-7 seconds is in each case ridicously short compared with the drawing period of ~ 10^-1 sec. 2. "Your code" takes -- depending on the input -- 5-20% _more_ time than "mine".
Leaving the mod-ing to the sin/cos functons saves again 10-15% of time.

All this applys of course only to my system. (Even if one could assume it for the majority of implementations comparing the speed of library functions is like debating about grains of sand whilst heavy rocks lie in writing a clean algorithm.)

So long
Ingolf





reply via email to

[Prev in Thread] Current Thread [Next in Thread]