I am trying to calculate Avg cpu time of a certain thread, using rusage.
however, i am getting ‘RUSAGE_THREAD’ was not declared in this scope.
i am using
#include <sys/resource.h>
and compiling with -D_GNU_SOURCE
at the start of my code, and my Linux version is fine.
this is where i try to do the calculation:
struct rusage l_rusage;
int retVal = getrusage(RUSAGE_THREAD, &l_rusage);
u64 userUSeconds = (static_cast<u64>(l_rusage.ru_utime.tv_sec)) * 1000000 +
(static_cast<u64>(l_rusage.ru_utime.tv_usec));
u64 systemUSeconds = (static_cast<u64>(l_rusage.ru_stime.tv_sec)) * 1000000 +
(static_cast<u64>(l_rusage.ru_stime.tv_usec));
return (userUSeconds + systemUSeconds) / ACE_OS::num_processors_online();
Any ideas? or maybe even a different solution? i am using ACE libs as well, so i have the ACE_OS, but i couldn't find the equivalent for RUSAGE_THREAD when trying to use ACE_OS::rusage.
Thank you
EDIT: Also another thing, i cant access to where the thread making code is actually, i can only use code from within the thread.