VMware Cloud Community
superryu
Contributor
Contributor

Get process time is wrong on Windows

I was getting very odd values from  sigar_proc_time_get(). I looked over the source and FILETIME2MSEC() is not converting the FILETIME to milliseconds correctly. I changed it to:

    ULARGE_INTEGER sys, user;

...

    memcpy(&sys,&system_time,sizeof(FILETIME));
    memcpy(&user,&user_time,sizeof(FILETIME));

    proctime->user = user.QuadPart /10000; //convert to ms //FILETIME2MSEC(user_time);
    proctime->sys  = sys.QuadPart /10000;

Not sure what FILETIME2MSEC is meant for but it's not correctly used here. sigar_proc_cpu_get relies on this to calucate the cpu % for a pid. Any bug filed against this?

Thanks,
Howard

Reply
0 Kudos
0 Replies