Does anyone now of a good way to use timers in C++? I've tried using clock_t, but it keeps returning 0:Code:clock_t start = clock();
//Do stuff....
clock_t end = clock();
double elapsed = static_cast<double>((end-start)/CLOCKS_PER_SEC);
Printable View
Does anyone now of a good way to use timers in C++? I've tried using clock_t, but it keeps returning 0:Code:clock_t start = clock();
//Do stuff....
clock_t end = clock();
double elapsed = static_cast<double>((end-start)/CLOCKS_PER_SEC);
What is returning 0? Is it clock or your elapsed calculations? You should cast end-start to double and then perform the division. If you need more precision you should probably look into more platform specific timing mechanisms.
Elasped equals 0. Thanks for the tips, seperating the division worked.