Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <math.h>
- #include <time.h>
- #include <Windows.h>
- using namespace std;
- //based on:
- // http://stackoverflow.com/questions/19378805/measure-cpu-time-on-windows-using-getprocesstimes
- static double cpuTime ( void ) {
- FILETIME createTime, exitTime, kernelTime, userTime;
- if (GetProcessTimes( GetCurrentProcess(), &createTime, &exitTime,
- &kernelTime, &userTime ) != -1) {
- SYSTEMTIME userSystemTime;
- if (FileTimeToSystemTime( &userTime, &userSystemTime ) != -1)
- return (double) userSystemTime.wHour * 3600.0 +
- (double) userSystemTime.wMinute * 60.0 +
- (double) userSystemTime.wSecond +
- (double) userSystemTime.wMilliseconds / 1000.0;
- }
- return -1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement