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.

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

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.

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

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.