1

I have two programs, one in go and one in python that I am trying to characterize. For this, I'd like to measure the CPU usage and Memory Usage by regularly measuring the amounts consumed by the two programs at regular intervals (say, every 0.1 seconds) for some given amount of time. I have been looking everywhere for any sort of solution to this problem, but I can't find any.

Does a good solution to this exist? If so, what?

Johnney
  • 161
  • 1
  • 9
  • Does [this](https://stackoverflow.com/questions/131303/how-can-i-measure-the-actual-memory-usage-of-an-application-or-process) help somehow? I see that it would require a profiler and that `ps` may not be the best option – ignacio Nov 23 '22 at 21:37
  • could you use `top` or `htop` commands? – ignacio Nov 23 '22 at 21:38
  • I looked at both of those, and neither of them quite suit my needs, unless my understanding of them is completely incorrect. I actually want to take measurements of the programs at regular intervals as they are running, (Specifically how many resources they are consuming), so I can analyze it at a later date – Johnney Nov 23 '22 at 23:31

2 Answers2

1

You can also try Check server load with top, htop, iotop.

Mark Smith
  • 21
  • 1
1

For my particular case, the best choice is to instrument the each of the programs for something like Prometheus. Then I can scrape the data at regular intervals to get what I am looking for.

In this case, I would follow off of something like: https://prometheus.io/docs/guides/go-application/

Or: https://linuxhint.com/monitor-python-applications-prometheus/

Johnney
  • 161
  • 1
  • 9