40#if defined(__unix__) || defined(__APPLE__)
41#include <sys/resource.h>
42#elif defined(_MSC_VER)
57#if defined(__unix__) || defined(__APPLE__)
59 if( getrusage(RUSAGE_SELF, &ru) == 0 )
61 userSeconds = (double)ru.ru_utime.tv_sec + (
double)ru.ru_utime.tv_usec * 1e-6;
62 systemSeconds = (double)ru.ru_stime.tv_sec + (
double)ru.ru_stime.tv_usec * 1e-6;
67#elif defined(_MSC_VER)
73 FILETIME ftCreationTime, ftExitTime, ftKernelTime, ftUserTime;
74 if( GetProcessTimes( GetCurrentProcess(),
75 &ftCreationTime, &ftExitTime, &ftKernelTime, &ftUserTime ) )
78 u.LowPart = ftUserTime.dwLowDateTime; u.HighPart = ftUserTime.dwHighDateTime;
79 k.LowPart = ftKernelTime.dwLowDateTime; k.HighPart = ftKernelTime.dwHighDateTime;
80 userSeconds = (double)u.QuadPart / 1.0e7;
81 systemSeconds = (
double)k.QuadPart / 1.0e7;
89 userSeconds = (double)std::clock() / (double)CLOCKS_PER_SEC;
108 stopPoint = std::chrono::steady_clock::now();
117 return std::chrono::duration<double>(
startPoint.time_since_epoch() ).count();
125 return std::chrono::duration<double>( std::chrono::steady_clock::now() -
startPoint ).count();
double sTimeStart
process system CPU seconds at start()
double getUTime(void)
get user time between start timne and stop time
double uTimeStop
process user CPU seconds at stop()
double getSTime(void)
get system time between start timne and stop time
void stop(void)
stop timer
double getStartTime(void)
get start time
double uTimeStart
process user CPU seconds at start()
double getRTimeInterval(void)
get elapsed time from start time
double sTimeStop
process system CPU seconds at stop()
std::chrono::steady_clock::time_point startPoint
real time at start()
std::chrono::steady_clock::time_point stopPoint
real time at stop()
double getRTime(void)
get real time between start timne and stop time
static void readProcessCpuTime(double &userSeconds, double &systemSeconds)
read the process' user / system CPU time in seconds