I need to measure the cpu usage of individual threads on darwin. On linux I use getrusage(RUSAGE_THREAD, …) but it’s not available on darwin.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
RUSAGE_THREAD flag of getrusage is Linux-specific.
getrusage of xnu does output only per-process sum.
Information about usage times of each thread is maintained in
task_basic_infostruct of each thread.Documentation is here http://www.gnu.org/software/hurd/gnumach-doc/Task-Information.html
Here is a simple example of how to get
task_basic_infostructhttp://blog.kuriositaet.de/?p=257