analysis of time consumed by a function in run time operation

Discussion in 'Embedded Systems and Microcontrollers' started by ak52, Dec 10, 2015.

  1. ak52

    Thread Starter Member

    Oct 15, 2014
    145
    4
    Hello Everyone,

    Is there a better way or a more accurate of analyzing the amount of time a function takes to execute.Currently i am doing it like this.

    start_timer();
    display_lcd_data(); //function which is to be analyzed.
    stop_timer();
    read_timer_value();

    My program had a few regular ISRs(interrupt service routines) so i need to know that the given function should finish its execution before the next ISR comes in.

    Thanks,
    AK
     
  2. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    7,394
    1,606
    The best way will accurately cont every machine cycle your measured routine requires. Errors begin when the count is larger or smaller.

    No one but you has any idea how accurate your method is since you have not disclosed the method, the machine, the compiler, or any details whatsoever.

    Some packages have simulators that can run code and count machine cycles for you. They work without adding any extra code.

    Do be aware that the very same routine can have a variable time to complete depending on the data it is processing.
     
  3. ak52

    Thread Starter Member

    Oct 15, 2014
    145
    4
    I am using a dsPIC33E,compiler XC16,debugger is Pickit3.
    A little bit of looking around here i found the stop watch feature ,which is exactly what i need :)

    Many Thanks,
    AK
     
Loading...