Your code is running too fast to be detected by the time function, which returns the number of seconds elapsed from 00:00 hours, January 1, 1970 UTC.
Try using this piece of code:
inline long getCurrentTime() { timeb timebstr; ftime( &timebstr ); return (long)(timebstr.time)*1000 + timebstr.millitm; }
To use it, you must enable sys / timeb.h.
Actually, the best practice is to repeat your calculations in a loop to get more accurate results.
source share