I am new to C++ , I have a program in C++ written for Linux. I\'m trying to convert it to Windows. The code I have is:
struct Timer
{
struct tms t[2];
This is (an untested, but logically correct) drop in replacement. The usertime
function returns in second resolution (as a double
) so you need to divide by the required resolution.
struct Timer
{
__int64 t[2];
void Start()
{
QueryPerformanceCounter((LARGE_INTEGER*)&t[0]);
}
void Stop()
{
QueryPerformanceCounter((LARGE_INTEGER*)&t[1]);
}
double usertime()
{
__int64 freq;
QueryPerformanceFrequency((LARGE_INTEGER*)&freq);
return (double(t[1] - t[0])) / freq;
}
};