Advertisement
Guest User

Untitled

a guest
Feb 8th, 2016
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. #include <iostream>
  2. #include <math.h>
  3. #include <time.h>
  4. #include <Windows.h>
  5.  
  6. using namespace std;
  7.  
  8. //based on:
  9. // http://stackoverflow.com/questions/19378805/measure-cpu-time-on-windows-using-getprocesstimes
  10. static double cpuTime ( void ) {
  11. FILETIME createTime, exitTime, kernelTime, userTime;
  12.  
  13. if (GetProcessTimes( GetCurrentProcess(), &createTime, &exitTime,
  14. &kernelTime, &userTime ) != -1) {
  15. SYSTEMTIME userSystemTime;
  16. if (FileTimeToSystemTime( &userTime, &userSystemTime ) != -1)
  17. return (double) userSystemTime.wHour * 3600.0 +
  18. (double) userSystemTime.wMinute * 60.0 +
  19. (double) userSystemTime.wSecond +
  20. (double) userSystemTime.wMilliseconds / 1000.0;
  21. }
  22. return -1;
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement