QueryPerformanceFrequency and QueryPerformanceCounter for Linux

62 Views Asked by At

I am trying to write a equivalent in Linux to this function in Windows:

double CputimeInUsecs()
    {
        double RetCputime = 0;
        LARGE_INTEGER   performanceCounter = {};
        LARGE_INTEGER   performanceFrequency = {};
            QueryPerformanceFrequency(&performanceFrequency);
            GEN_IGNORE(QueryPerformanceCounter(&performanceCounter));
        RetCputime = static_cast<double>(performanceCounter.QuadPart) / (static_cast<double>(performanceFrequency.QuadPart) / 1000000.0);
        return RetCputime;
    }

I read at some places that clock_gettime when passed with CLOCK_PROCESS_CPUTIME_ID might solve the issue , but I am not sure about it. What is the possible implementation of this in Linux?

0

There are 0 best solutions below