Skip to content

Instantly share code, notes, and snippets.

@divinity76
Created February 24, 2015 16:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save divinity76/e7be8aafe32d66e465f9 to your computer and use it in GitHub Desktop.
Save divinity76/e7be8aafe32d66e465f9 to your computer and use it in GitHub Desktop.
unsigned __int64 freq;
QueryPerformanceFrequency((LARGE_INTEGER*)&freq);
double timerFrequency = (1.0 / freq);
unsigned __int64 startTime;
QueryPerformanceCounter((LARGE_INTEGER *)&startTime);
int_fast32_t i = 0;
for (i = 0; i < 1000; ++i){
Sleep(1);
}
unsigned __int64 endTime;
QueryPerformanceCounter((LARGE_INTEGER *)&endTime);
double timeDifferenceInMilliseconds = ((endTime - startTime) * timerFrequency);
std::cout << "used " << timeDifferenceInMilliseconds << " seconds to Winapi Sleep 1 ms, 1000 times" << std::endl;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment