Yeah MS should really stay out of the atomic clock business!
Here's a simple busy loop by the way:
Code:
void wait( unsigned int time_out )
{
time_t finish = GetTickCount()+time_out;
while(GetTickCount() < finish) continue;
}
And a very unscientific way to control speed of execution:
Code:
/* pass 0 into function to get you're cpu's 'constant', otherwise, pass your 'constant' in to calculate an approximate ratio of user's cpu speed to the speed you compiled at...*/
double cpu_factor(double constant, short num_averages = 1)
{
time_t start;
double end_time;
double average = 0;
short loops;
int i;
if(num_averages == 0)
num_averages = 1;
for(loops = 0; loops < num_averages; ++loops)
{
i = 0;
start = clock();
while(++i <= 10000000)
continue;
end_time = (double)( clock()- start );
average += end_time;
}
average /= loops;
if(constant == 0)
{
return average;
}
else return average/constant;
}
Example:
Code:
const double my_cpu = 260; /* compiled cpu_factor() */
double this_cpu;
int main()
{
this_cpu = cpu_factor(my_cpu);
}