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

Discussion in 'Embedded Systems and Microcontrollers' started by davidbp.13, Feb 9, 2016.

  1. davidbp.13

    Thread Starter New Member

    Feb 9, 2016
    2
    0
    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).
     
  2. Picbuster

    Member

    Dec 2, 2013
    374
    50
    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).
     
  3. Papabravo

    Expert

    Feb 24, 2006
    10,140
    1,789
    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.
     
  4. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    7,386
    1,605
    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.
     
  5. davidbp.13

    Thread Starter New Member

    Feb 9, 2016
    2
    0
    Sounds good. Wich compiler do you recommend?
     
Loading...