Skip to content

Instantly share code, notes, and snippets.

@karolzlot
Last active May 7, 2024 08:56
Show Gist options
  • Star 14 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save karolzlot/26864e21e7347ce41f71f87f156ea266 to your computer and use it in GitHub Desktop.
Save karolzlot/26864e21e7347ce41f71f87f156ea266 to your computer and use it in GitHub Desktop.
Monitoring real time cpu and ram usage with tqdm. If you like it please upvote this answer: https://stackoverflow.com/a/69511430/8896457
from tqdm import tqdm
from time import sleep
import psutil
with tqdm(total=100, desc='cpu%', position=1) as cpubar, tqdm(total=100, desc='ram%', position=0) as rambar:
while True:
rambar.n=psutil.virtual_memory().percent
cpubar.n=psutil.cpu_percent()
rambar.refresh()
cpubar.refresh()
sleep(0.5)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment