Search⌘ K

Instructions for Exercise

Explore how to test and measure swap performance by running a program that allocates and increments an integer array. Understand memory allocation impact, bandwidth calculations, and use vmstat to monitor system memory activity during swapping.

We'll cover the following...

In this exercise, you’ll be investigating swap performance with a simple program found in mem.c. The program is really simple: it just allocates an array of integers of a certain size, and then proceeds to loop through it (repeatedly), incrementing each value in the array.

all: mem

mem: mem.c
	gcc -o mem mem.c -Wall -O

Press the RUN button to open a terminal through which you can interact with the code.

Once the terminal is launched, type make to build it (and look at the file Makefile for details about how the build works).

Then, type ./mem followed by a number to run it. The number is the size (in MB) of the array. Thus, to run with a small array (size 1 MB): ...