How to know how many resource thread use?

Viewed 38

I have a source code that is using some threads.

I want to see how many percent cpu and percent memory are used each threads.

So I used "htop" command. (I am using ubuntu.)

There are "PID" columns which is Process/thread ID.

I googled how to get thread id.

  1. https://en.cppreference.com/w/cpp/thread/thread/id/hash
  2. How to convert std::thread::id to string in c++?

But, somehow the thread ids I got from source code are not matched with PID values, one of htop command's output.

Any better idea or help would be great, thank you.

1 Answers

PID is Process ID. Run top -H

man 1 top

-H  :Threads-mode operation
     Instructs top to display individual threads.  Without this
     command-line option a summation of all threads in each
     process is shown.  Later this can be changed with the `H'
     interactive command
Related