This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

code timing measurement

Hi all,

I want to measure timing of some functions.

for that i know two methods,

1) code profiling using CCS as explained in

processors.wiki.ti.com/.../Profile_clock_in_CCS

2) time measurement on scope with GPIO on-off

I want to know which one is reliable and accurate.

what are tradeoff of both the methods?

  • The GPIO will add a little overhead, because you have to be able to set a GPIO and reset the same GPIO. However, it will give you the best "feel" for how long it takes your code to go from point A to point B. There are times that you may want to look at multiple threads, and that is done very well with GPIOs. For instance, you may want to look at how long it takes from an ADC isr until a task associated with that isr is started and the duration of time for each.
  • Keyur, the best and the most efficient method I've found is using the inbuilt timers. Start the CPUtimer whenever required and stop it accordingly. You get the counts which you can convert into time.

    Regards,
    Gautam
  • I am measuring time from both the above mentioned method and i can see so much difference.
    I have configured one interrupt of 100uS

    1) using profile clock i measured ticks it shows 1604 ticks and device is running on 90MHz .
    time would be 1604/90 = 17 uS.

    2)by using GPIO on off i get 100uS

    what could be wrong with profile clock?

    Regards,

    Keyur

  • Keyur:
    I know that there were some problems in the past with CCS support of the profile clock. It may depend on which version you are using.
    The start/stop of the profile clock can be somewhat tricky at times, and because it gives you an answer in "ticks" rather than time, I tend to use it less frequently than GPIO. There are times that you want to look at interaction of interrupts and associated code, and that is where I have seen GPIO method to be very beneficial.
  • Gautam,
    main problem with cpu timing is that
    1] I have to modify my existing code
    2] some time after adding all the functionality I don't have timers remaining.
    That's why i was wondering if i could solely depend on profile clock or not.
  • Todd,
    I also think that i should not rely much on profile clock as off now.
    I asked this question to verify that is there anything special to take care during time measurement with profile clock
    Regards,
    Keyur
  • CCS Clock profiler is pretty much accurate. But I do personally believe in what I see on the scope instead on the number given by the CCS. But I've verified my observations with CPU clock counts and they seem nearer. There's nothing special to take care of - for profile clock.

    Regards,
    Gautam