Advertisement
Ember

time

Jan 28th, 2015
215
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.60 KB | None | 0 0
  1. LARGE_INTEGER li;
  2. Double frequency;
  3. Double time;
  4. HRESULT hresult;
  5.  
  6. // Get the high-resolution timer frequency
  7. hresult = QueryPerformanceFrequency(&li);
  8. if(!hresult) { return false; }
  9.  
  10. // Set the timer frequency to milliseconds
  11. frequency = (double)li.QuadPart / 1000.0;
  12.  
  13. // Reset the timer
  14. QueryPerformanceCounter(&li);
  15. time = li.QuadPart;
  16.  
  17. // Stuff goes here
  18.  
  19. // Get the elasped time
  20. QueryPerformanceCounter(&li);
  21. time = li.QuadPart - time;
  22. time /= frequency;
  23.  
  24. // Time stuff goes here
  25.  
  26. // Reset the timer
  27. QueryPerformanceCounter(&li);
  28. time = li.QuadPart;
  29.  
  30. // Go back to the stuff goes here
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement