dodo
0.0.1
A C++ library to create containerized Linux services
|
Go to the documentation of this file.
26 #include <sys/syscall.h>
36 t->
tid_ =
static_cast<pid_t
>(syscall(SYS_gettid));
40 return static_cast<void*
>(t);
71 getrusage( RUSAGE_THREAD, &
rusage_ );
77 return std::thread::id();
117 return ( ( (
double)
rusage_.ru_utime.tv_sec + (
double)
rusage_.ru_utime.tv_usec/1.0E6 ) -
122 return ( ( (
double)
rusage_.ru_stime.tv_sec + (
double)
rusage_.ru_stime.tv_usec/1.0E6 ) -
127 return ( ( (
double)
rusage_.ru_minflt ) -
132 return ( ( (
double)
rusage_.ru_majflt ) -
137 return ( ( (
double)
rusage_.ru_inblock ) -
142 return ( ( (
double)
rusage_.ru_oublock ) -
147 return ( ( (
double)
rusage_.ru_nvcsw ) -
152 return ( ( (
double)
rusage_.ru_nivcsw ) -
virtual void run()=0
Decsendants must override the run function.
double getAvgVCtx()
Get the average voluntary context switch rate since thread start()
double getAvgMinFltRate()
Get the average minor fault rate since thread start()
std::thread * thread_
The std::tread object.
void wait()
Wait for the thread to join the current thread / wait for the thread to finish.
double getRunTime()
Time, in seconds, since thread start.
double getLastMinFltRate()
Get the minor fault rate since last sample.
double getLastMajFltRate()
Get the major fault rate since last sample.
double getLastBlkInRate()
Get last block in rate since last sample.
double getAvgUserCPU()
Get the average user mode cpu (cpu seconds/second) since thread start()
double getLastUserCPU()
Get the user mode cpu (cpu seconds/second) since last sample.
double getLastBlkOutRate()
Get last block out rate since last sample.
void start()
Start the thread.
double getLastICtx()
Get involuntary context switch rate since last sample.
struct rusage rusage_
Last statistics.
struct rusage prev_rusage_
Previous statistics.
std::thread::id getId() const
Get the thread id.
double getAvgICtx()
Get the average involuntary context switch rate since thread start()
void snapRUsage()
Take a snapshot of the thread's resource usage.
double getAvgMajFltRate()
Get the average major fault rate since thread start()
struct timeval snap_time_
Time of last statistics snapshot.
double getSecondDiff(struct timeval &t1, struct timeval &t2)
Return difference in seconds as a double.
struct timeval prev_snap_time_
Time of previous statistics snapshot.
long getMaxRSS()
Get the maximum resident set size seen on the thread.
double getAvgBlkInRate()
Get the average block in rate since thread start()
double getSnapDiffTime()
Time, in seconds, since last statistic update.
double getLastSysCPU()
Get the system mode cpu (cpu seconds/second) since last sample.
double getAvgSysCPU()
Get the average system mode cpu (cpu seconds/second) since thread start()
virtual ~Thread()
Destructor.
Interface for Thread programming.
double getLastVCtx()
Get voluntary context switch rate since last sample.
struct timeval start_time_
Time Thread started.
static void * thread_method(void *context)
Posix thread method - calls dodo::threads::Thread:::run().
double getAvgBlkOutRate()
Get the average block out rate since thread start()