Cool the new timer is working great! However, im having a new problem.
For some bizzare reason, im noticing little spikes (about 16ms with the dbTimer() and 1-5ish ms with perfTimer() ). The spikes only happen if you try and clock particular functions (usually the more intense ones), but the spikes are ALWAYS for the exact same amount it seems (thus I dont think its the code causing the spike, but something else).
Is it normal for these timer functions to sometimes cause spikes like this? Even if it is, why does it seem to only happen when I time particular functions? If I just time empty space (ttStart(); ttStop(); ) I never see these spikes. And I dont think it cant be the systems (code) itself, because like I said, I get the same spike when I time completely different systems (16ms with dbTimer() 5ish with perfTimer()).
Could it be my timer code? Here it is...
//===============
//TICK TOCK TIMER
//===============
int ttBuffer[99];
int ttPos = 0;
int ttBegin = 0;
int ttSpike = 0;
void ttStart ( void ) {
if (dbShiftKey()) ttSpike = 0;
ttBegin = dbTimer();
//ttBegin = perfTimer();
} //end ttStart()
void ttStop ( void ) {
ttBuffer[ttPos] = dbTimer() - ttBegin;
//ttBuffer[ttPos] = perfTimer() - ttBegin;
if ( ttBuffer[ttPos] > ttSpike ) ttSpike = ttBuffer[ttPos];
ttPos++; if (ttPos > 99) ttPos = 0;
float a = 0.0f;
for (int i = 0; i < 99; i++) {
a += ttBuffer[i];
}
dbText(256,0,dbStr( (a/100) ));
dbText(256,18,dbStr( ttSpike ));
//dbText(256,0,dbStr( (a/100)*0.001f ));
//dbText(256,18,dbStr( ttSpike*0.001f ));
} //end ttStop()
All you need is zeal