如何测量当前在Linux上使用的内存带宽? [英] How to measure memory bandwidth currently being used on Linux?

查看:2320
本文介绍了如何测量当前在Linux上使用的内存带宽?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在写一个小型Linux应用程序,记录计算机的功耗以及CPU利用率和磁盘利用率。我想添加记录当前使用的内存带宽的能力,这样我就可以看到与功耗相关的程度。

I'm writing a small Linux application which logs the computer's power consumption along with CPU utilisation and disk utilisation. I'd like to add the ability to log memory bandwidth currently being used so I can see how well that correlates with a power consumption.

我知道我可以获得信息关于当前从 / proc / meminfo 分配的内存量,但当然不告诉我有多少带宽目前正在使用。有没有人知道我如何测量当前使用的内存带宽?

I understand that I can get information about the amount of memory currently allocated from /proc/meminfo but, of course, that doesn't tell me how much bandwidth is being used at present. Does anyone know how I could measure memory bandwidth currently in use?

编辑
我想这主要工作在x86和x86-64平台

edit I'd like this to work primarily on the x86 and x86-64 platforms

推荐答案

这是高度CPU依赖,但你需要能够访问CPU性能寄存器。你可以通过oprofile来做到这一点。注意,并非所有的CPU都有一个性能寄存器(或寄存器组合),可用于计算内存带宽使用。

It's highly CPU-dependent but you'll need to be able to get access to the CPU's performance registers. You may be able to do this via oprofile. Note that not all CPUs have a performance register (or combination of registers) which can be used to calculate to memory bandwidth usage, however.

这篇关于如何测量当前在Linux上使用的内存带宽?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆