I dont know if it will help, or if this function has any overhead, but the standard c/c++ function GetTickCount() will return a Long int of milliseconds.
The program
#include <cstdio>
using namespace std;
long the_time = 0;
long last_time = 0;
long frame_time = 0;
void frame(void)
{
this_time = GetTickCount();
frame_time = the_time - last_time; // this is time elapsed since last call
if(frame_time == 1) // one millisecond
{
// perform processing of data
}
last_time = the_time;
return;
}
int main(void)
{
for(;;) { frame(); }
return 0;
}
gets the time every time the frame is called. If you print the time you find that on most recent systems the processing is enough that i have found even on my 2.5GHz celeron that from that loop i could get quite a few calls before one millisecond was up. The IF statement effectively is called every millisecond, on paper anyway. I could not garuntee the accuracy or any overheads. It might be worth turning this code over to the computer science forum as i believe they might be able to help with timing and accuracy of code and computing a lot more :)