How can I measure of execution time and memory usage of C implemented libraries?

Thread Starter

davidbp.13

Joined Feb 9, 2016
2
Hello.

I have the task of evaluate functions of C implemented libraries that will run on embedded systems. Those libraries are implemented in .h files and then included in implementations.

I was given a FFT library implemented in C that was meant to run on Arduino. In the readme file of the library there are two charts measuring execution time, RAM and FLASH usage of each of the functions that compose the library. I need to find a way to make those measurements and see if they match with what is given in that file.

I managed to evaluate execution time using Arduino and running micros() before and after the function and then measuring the time difference and I got good results. But I still haven't found a way of measuring memory usage. I need to find a way of measuring FLASH (memory that takes the code itself) for each function and SRAM (global and local variables) also for each function. I need to find a compiler that provides a memory map, or a code to make the measurement or something similar. I know that measuring dynamic data can be tricky so by far I have just tried to use the MemoryFree library for Arduino and the information that the compiler provides but got no useful results since I need it for every function and not for the hole code and also because the mentioned library gave no useful results. I have also googled a lot but found nothing.

I really appreciate if someone know how to do that or know where can I find useful information about it.

Thanks in advance.

PS: Attached you can find the FFT library (including the readme file with the charts).
 

Attachments

Picbuster

Joined Dec 2, 2013
1,047
Use a logic analyser and measure ready, enable and data stream time at the flash.
This should give a good indication of the flash 'speed' and could indicate that your sw timing at enable could be improved.
(idle time enable).
 

Papabravo

Joined Feb 24, 2006
21,158
Estimating memory usage can be a challenge. I suggest using an object listing and linker load map which most compilers will produce, or an object dump tool which is part of all GCC compilers. RAM usage is harder to quantify because there are several types. There is temporary storage on the stack, there are static local variables, and there are global variables. Each one will require different techniques.
 

ErnieM

Joined Apr 24, 2011
8,377
Most compilers will give you a total memory usage number, though I am not familiar with the Arduino.

A quick and dirty way (but rather effective too) is to build your code first with the required library, then without it.

Note the build size difference and you have your answer.
 

Thread Starter

davidbp.13

Joined Feb 9, 2016
2
Estimating memory usage can be a challenge. I suggest using an object listing and linker load map which most compilers will produce, or an object dump tool which is part of all GCC compilers. RAM usage is harder to quantify because there are several types. There is temporary storage on the stack, there are static local variables, and there are global variables. Each one will require different techniques.
Sounds good. Wich compiler do you recommend?
 
Top