英文:
Measure CPU Usage (in Cores) and Memory Usage of Compiled Programs
问题
我有两个程序,一个是用Go语言写的,一个是用Python写的,我想对它们进行特征化。为此,我想通过定期测量两个程序在一段给定时间内的CPU使用率和内存使用情况来衡量。我已经到处寻找解决这个问题的方法,但是找不到任何解决方案。
是否存在一个好的解决方案?如果有,是什么?
英文:
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?
答案1
得分: 1
你也可以尝试使用top、htop和iotop来检查服务器负载。
英文:
You can also try Check server load with top, htop, iotop.
答案2
得分: 1
对于我的特定情况,最好的选择是为每个程序添加类似Prometheus的仪表盘。然后我可以定期抓取数据以获取我所需要的内容。
在这种情况下,我可以参考以下链接:https://prometheus.io/docs/guides/go-application/
或者:https://linuxhint.com/monitor-python-applications-prometheus/
英文:
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/
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论