测量编译程序的CPU使用率(以核心为单位)和内存使用情况。

huangapple go评论86阅读模式
英文:

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/

huangapple
  • 本文由 发表于 2022年11月24日 03:32:37
  • 转载请务必保留本文链接:https://go.coder-hub.com/74552123.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定