0

I've programmed different scripts and want to compare them regarding the CPU usage and the memory usage. I wanted to use https://psutil.readthedocs.io/en/latest/ to get the needed data but as my scripts have different execution times I'm wondering if psutil is the right library to go for. The scripts runtimes vary from 0.005 seconds to 3 seconds, so I can't really use functions like psutil.cpu_percent(interval = 1).

Thanks in advance!

learnPyt
  • 41
  • 5
  • Does [this post](https://stackoverflow.com/questions/276052/how-to-get-current-cpu-and-ram-usage-in-python) answer your question? – tax evader Jul 28 '21 at 15:20
  • Runetimes vary from 0.005 to 3 seconds is a pretty big difference. Does it depend on the user input or file inputs or it has a random runtime within that interval – tax evader Jul 28 '21 at 15:23
  • @user696969 well the post you've mentioned also directs to psutil. my problem is that since runtime is sometimes so low I can't really use psutil as I'd need a measure frequence of 0.001 seconds or something? I'm comparing different algorithms. Thats why the runtime varies so much. Basically I want to monitor how much ressources the different algorithms need. – learnPyt Jul 29 '21 at 10:03
  • @user696969 I'm pretty much looking for the same thing as https://stackoverflow.com/questions/34391027/how-to-profile-a-certain-function-in-python but there was no answer on that one – learnPyt Jul 29 '21 at 19:02

0 Answers0