With meminfo you can get memory information about your process or other processes.
The following code demonstrates how it works:
//Initial memory usage
printMemUsage();
//Memory usage after stack allocation
char c[1024];
printMemUsage();
//Memory usage after heap allocation
char *test = (char*)malloc(sizeof(char) * 409600);
printMemUsage();
//Memory usage after heap deallocation
free(test);
printMemUsage();
printMemUsage does the following:
static struct meminfo m;
get_own_meminfo(&m);
printf("Referenced: %d kB\n", m.referenced_KB);
This will print the following:
Referenced: 468 kB
Referenced: 480 kB
Referenced: 484 kB
Referenced: 480 kB
This code is included in test.c
My Raspberry Pi is able to perform 1000 measures in 1.51 seconds