Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Equivalent to RUSAGE_THREAD darwin?

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.

like image 223
melisgl Avatar asked Jun 07 '26 05:06

melisgl


1 Answers

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_info struct 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_info struct http://blog.kuriositaet.de/?p=257

 task_info(mach_task_self(), TASK_BASIC_INFO, (task_info_t)&t_info, &t_info_count)
like image 148
osgx Avatar answered Jun 10 '26 09:06

osgx



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!