I run C++ program in Linux.
There are several threads pool (for computation, for io, for ... such things).
The system call clock() gives me a way to measure the CPU time spent by all the CPU cores for the process.
However, I want to measure the CPU time spent only by the threads in the computation threads pool.
How can I achieve it?
Thanks :D
To get
CPU clock ID
of every thread you can use: pthread_getcpuclockid and using thisCPU clock ID
you can retrieve the current thread CPU time using: clock_gettime.Following is the sample code to demonstrate the same: