Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to measure memory bandwidth currently being used on Linux?

Tags:

c++

linux

memory

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.

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?

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

like image 845
Jack Kelly Avatar asked Jun 28 '11 08:06

Jack Kelly


1 Answers

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.

like image 193
Paul R Avatar answered Sep 21 '22 19:09

Paul R