Getting a per thread cpu stats

Solution 1:

top -H -p pid 

hope it can help

Solution 2:

Percent of cpu usage per thread you can get with ps command:

 ps -emo %cpu,pid,user,args

The way it is calculated is described in ps manpage:

Currently, it is the CPU time used divided by the time the process has been running (cputime/realtime ratio), expressed as a percentage.


Solution 3:

I'd look into SystemTap. This tool will certainly give you what you want. There is this example of profiling threads; don't know if it has all you want, but you could modify it so that it does.

Tags:

Linux

Threads