A friend suggested some profiling for a previous project so I figured that would also be the best way to solve this question.
#include "DarkGDK.h"
#include <math.h>
// Functions
// Global vars
float c = 0.0;
float DefaultZ = 10.0;
// Global constants
// Entry point
void DarkGDK ( void )
{
// test
int t, t1, t2, CurX = 0, CurY = 0;
while ( LoopGDK ( ) )
{
int t = dbTimer();
for (float i = 0.0; i <= 1000000; i+=1.0) {
//sin(i);
//cos(i);
//tan(i);
//acos(i);
atan(i);
//cosh(i);
//sinh(i);
//tanh(i);
//sqrt(i);
}
t1 = dbTimer() - t;
t = dbTimer();
for (float i = 0.0; i <= 1000000; i+=1.0) {
//dbSin(i);
//dbCos(i);
//dbTan(i);
//dbAcos(i);
dbAtan(i);
//dbHcos(i);
//dbHsin(i);
//dbHtan(i);
//dbSqrt(i);
}
int t2 = dbTimer() - t;
dbCLS();
dbSetCursor(0,0);
dbPrint(dbStr(t1));
dbSetCursor(0,12);
dbPrint(dbStr(t2));
dbSetCursor(64,12);
dbPrint( dbStr( t1/t2 ));
dbSetCursor(64,0);
dbPrint( dbStr( t2/t1 ));
dbSync();
}
}
This is one of my most used and basic ways of comparing function speeds. You'll have to uncomment the functions you want to test against each other. You could use this for other functions too.
I found that the base cos, sin, tan functions are slower than their DB counterparts in most cases. But it's not the same for atan, acos, asin... they are faster when using the math.h version. You may get different results though... this somehow doesn't seem like the best way to test them what with different processors all over the place.