简体   繁体   English

测量 CPU 使用率(以内核为单位)和编译程序的 Memory 使用率

[英]Measure CPU Usage (in Cores) and Memory Usage of Compiled Programs

I have two programs, one in go and one in python that I am trying to characterize.我有两个程序,一个在 go 中,另一个在 python 中,我正在尝试对其进行表征。 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.为此,我想测量 CPU 使用率和 Memory 的使用率,方法是定期测量两个程序在给定时间内(例如,每 0.1 秒)消耗的量。 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?如果是这样,什么?

You can also try Check server load with top, htop, iotop.您也可以尝试使用 top、htop、iotop 检查服务器负载。

For my particular case, the best choice is to instrument the each of the programs for something like Prometheus.对于我的特殊情况,最好的选择是为 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/在这种情况下,我会遵循以下内容: https://prometheus.io/docs/guides/go-application/

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM