I would like to measure the RAM usage of several desktop environments (including Cinnamon, GNOME, KDE, LXDE, LXQt, MATE and Xfce) running on my Sabayon machine. I would prefer a command-line way of checking RAM usage, if possible. I have tried using this ps_mem.py script (by running python ps_mem.py -p Cinnamon
for Cinnamon, for example) but unfortunately it requires PIDs for programs and will not simply accept the name of the DE and I'm not sure which programs belong to my DE and which do not.
1 Answer
You can put together a command that parses free
to tell you how much free memory you have:
free -h | awk {'print $3'} | head -3 | tail -1
1.8G
Run the bash script every half second to keep a record of your memory usage:
while true; do free | awk {'print $3'} | head -3 | tail -1 >> free.dat; sleep 0.5; done
For each environment you want to test, put that script in the list of automatically run programs (e.g., for Fluxbox it goes in ~/.fluxbox/startup
). You can readily view your plots by running gnuplot
and calling
gnuplot> plot 'free.fluxbox.dat' using 1 with impulses
Now, the hard part is your apples to apples comparison. If you want to see how memory usage looks after opening lots of programs, you can put this script in yet another script, followed by subsequent calls to libreoffice
, firefox
and gnome-system-monitor
, or whatever list you like. Alternatively, you could just open them manually, but that really doesn't seem like a tenable approach to honestly comparing environments.
-
I plan on writing a blog post on this, and hence I would like a nice singular number to present for each DE. Like an average, or RAM usage during boot, or etc. Like your answer seems wonderful if all my readers were mathematicians or statisticians but not humble Sabayon users. With that being said this answer is definitely a good effort, I realize I didn't give much specifics of what I wanted exactly. Commented Sep 28, 2015 at 20:36
-
@BrentonHorne Well that's disappointing. Anyway, you can get an average from the dat file by calling
awk '{s+=$1}END{print "avg:",s/NR}' RS=" " free.dat
after you're done running the script. Commented Sep 28, 2015 at 21:30 -
Btw what's the autostart script for the enlightenment DE? I have Googled for it but I can't seem to find it. Commented Sep 28, 2015 at 21:50
-
I've also noticed that
free.dat
for me only contains lines of the number168
. Which for me is odd as I'd expect my free RAM to vary with time. Commented Sep 28, 2015 at 22:49 -
@BrentonHorne If you're running
free
with the-h
flag (for human readable), it will output something in the MB or GB range since that's the easiest for humans to read. Try running without that flag to get the result in bytes. Commented Sep 29, 2015 at 0:17
htop
?