0

I have a multi processing program. I need to check it's CPU usage and other variables like heap memory usage and number of processes used.. number of thread used. how to do this? I just want to know how my code is effecting my system.

1 Answer 1

1

Using the psutil library saves a lot of work here.
You can install it via the various methods described on this page


Getting CPU usage, heap usage, thread count, and process count:

import psutil
import threading


print("CPU usage", psutil.cpu_percent())
print("HEAP usage", psutil.virtual_memory())
print("Active thread count", threading.active_count())
print("Process count", len([*psutil.process_iter()]))
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.