(edit: I'm done editing now, I promise. Maybe.)
The problem is that using precomputed tables results in higher CPU usage and that's confusing me. The routine which creates the table is in fact occurring outside of the applications render loop. It is NOT being recomputed every iteration.
So here are the details;
I've designed a class which executes some numerical algorithms and I've added some methods which allow user to specify the location to some precomputed tables to speed things up.
After the object is created I will attach the tables like so;
vector< vector< float > > *TCOS, *TSIN;
void ALG::UseTrigTables(vector< vector< float > > *fsin, vector< vector< float > > *fcos)
TCOS = fcos;
TSIN = fsin;
Within the class the tables are used like so;
vector< vector< float > >
tcos(N, vector< float > (N)),
tsin(N, vector< float > (N));
// [insert loop here to fill vector-vectors with data]... etc...
Why would that increase CPU usage?
for (int k = 0; k < N; ++k)
for (int j = 0; j < N; ++j)
f0 = fA[k] * fB[j] * (*TSIN)[k][j];
With trig: ~8%
With tables: ~10%
Where N = 128 (size of tables/loop)
My first guess;
While I am passing a pointer, maybe I'm missing something critical and the tables are actually being copied to a new location in memory every time i call them??
If not, what exact tools do you recommend I use to profile this applications behavior?