Cosine clock cycles

Hi,
I would like to know how many (epproximatly) clock cycles (calculate operations) it takes when I run the cos() function in C on linux ? ,and the same for a simple addition or multiplication.

if it is possible, i’d like a reference for an article or something like that.

thank’s, ofer.

Hey Ofer,

well, if you compiled cos() and looked at the asm you could then bust out the guide to your processor and see. I think the number of instructions it takes varies from processor to processor.

These things dont really matter anymore though because with modern CPU’s they do more than one instruction at a time and sometimes do them out of order so its really difficult to figure out how much time something takes.

Let me guess…your either comparing using cos() and using cos lookup tables or you are comparing cos() to a function you made that aproximates cos?

if i were you id benchmark the difference and be like “using my function, i can calculate 50 cosines in 2 seconds but using cos() i only get 20 in 2 seconds” those numbers of course are way off :stuck_out_tongue:

hope this helps

PS since this is an SDL list and not a C list you might try asking a C programming list or asking a C channel on irc. If you go onto the same server the official SDL room is and go into #gcc im sure you will find people who can answer this question a million times better than i did.

Atrix----- Original Message -----
From: Weissblum Ofer
To: sdl at libsdl.org
Sent: Tuesday, August 26, 2003 1:32 PM
Subject: [SDL] cosine clock cycles

Hi,
I would like to know how many (epproximatly) clock cycles (calculate operations) it takes when I run the cos() function in C on linux ? ,and the same for a simple addition or multiplication.

if it is possible, i’d like a reference for an article or something like that.

thank’s, ofer.

Hey Ofer,

well, if you compiled cos() and looked at the asm you could then bust out the guide to your processor and see. I think the number of instructions it takes varies from processor to processor.

These things dont really matter anymore though because with modern CPU’s they do more than one instruction at a time and sometimes do them out of order so its really difficult to figure out how much time something takes.

Let me guess…your either comparing using cos() and using cos lookup tables or you are comparing cos() to a function you made that aproximates cos?

if i were you id benchmark the difference and be like “using my function, i can calculate 50 cosines in 2 seconds but using cos() i only get 20 in 2 seconds” those numbers of course are way off :stuck_out_tongue:

hope this helps

PS since this is an SDL list and not a C list you might try asking a C programming list or asking a C channel on irc. If you go onto the same server the official SDL room is and go into #gcc im sure you will find people who can answer this question a million times better than i did.

Atrix----- Original Message -----
From: Weissblum Ofer
To: sdl at libsdl.org
Sent: Tuesday, August 26, 2003 1:32 PM
Subject: [SDL] cosine clock cycles

Hi,
I would like to know how many (epproximatly) clock cycles (calculate operations) it takes when I run the cos() function in C on linux ? ,and the same for a simple addition or multiplication.

if it is possible, i’d like a reference for an article or something like that.

thank’s, ofer.

Am I the only one that got 2 coppies of this? was it
Atrix? or the list?

-Loren

Re: [SDL] cosine clock cycles
— Atrix Wolfe wrote:
__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software

i think it was me…i tried to send and my comp crashed first time
around…sorry bout that> ----- Original Message -----

From: linux_dr@yahoo.com (Loren Osborn)
To:
Sent: Tuesday, August 26, 2003 9:20 PM
Subject: [SDL] duplicate post from Atrix Wolfe

Am I the only one that got 2 coppies of this? was it
Atrix? or the list?

-Loren

Re: [SDL] cosine clock cycles
— Atrix Wolfe <@atrix2> wrote:


Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl