Walker Lester
Walker Lester

Reputation: 11

Getting the total CPU usage in python 3 on windows

I am trying to write a program that can measure the overall CPU usage.

I tried using psutil.cpu_percent(), but it is returning the CPU usage for only the python process.

Upvotes: 1

Views: 802

Answers (1)

user20668417
user20668417

Reputation:

import psutil
psutil.cpu_percent(5)

Count it for multiple seconds, will return the average cpu usage in 5 seconds. psutil.cpu_percent() Only gets the usage in the current moment, Which can go from 1 to 50+ in a few ms.

Upvotes: 1

Related Questions