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.

How to Measure of Execution Time without including any header file?

Hi

Could someone help me to measure the runtime that a portion of code elapsed to execute?

The tricky part that we are using fixed point code and is not allowed to add a library nor to include header file since it will add more code.

I know there are many ways to do that and I reviewed them some of them such as:

1- QueryPerformanceCounter() and QueryPerformanceFrequency(), 

2- GetTimestamp()

3- GetTickCount()

4- clock(), time()

5- Time Stamp Counter Registers (TSCL and TSCH)  

but all need a header file or a library to add.

I want to use the (TSCH, TSCL) but it needs the header file (c6x.h),  I wonder if I could get the address of the counter (TSCH, TSCL) and then read the contents and do the calculation.

I'm using the processor TMS470 tool 4.4.16.

Our code is around 1.3 ms, so we need the measurement  to be in mircrosecond level.

Open for any new idea.

Thanks

habdulgh

 

 

  • How about the old tried and true method of setting a GPIO pin high at the start of the code of interest, and clearing the pin low at the end.  You can then measure the pulse width on a scope.

    Regards,

    David

  • GPIO pin will work,  but make sure to compensate for the delay for the processor just to toggle the IO with no software in between.

    It takes about 25 cycles to toggle an IO on the TMS570,  TMS470 is a lot less (don't know the exact #).  C6000 is probably in the 20+ cycle range too.

    So GPIO method works well but the body of code you're measuring needs to be farily large so that the error toggling the pin itself is negligible.

    I am not sure which processor the original question is about, especially since the TMS470 4.x compiler applies to many TI parts.  Also the header mentioned looked like C6000 which is a different CPU completely.

    But if you're trying to measure on the TMS570 (Cortex R4F) and don't want to edit your code, a quick and dirty idea is here:

    http://e2e.ti.com/support/microcontrollers/hercules/f/312/p/260549/911524.aspx#911524

    -Anthony

  • Thank you guys for your answers..

    Actually you went into different direction.

    The code that we have is embedded code that goes in CPU in Vehicle controllers.

    It has a different board that is not listed in the TMS family, and my code is part of a big code, we are using the TMS470  4.4.16 compiler only, and my code links with other obj files and the final executable file goes to CPU that I don 't have any control on the hardware.

    The measurement of the runtime should be done in the code, not in the hardware.

    The code is a fixed point, means not allowed to use any double or a decimal number, all variables are scaled.

    not allowed to include any header files , because if we did, means we need to include some library which means more code and more run time.

    I was hoping to get the address of (TSCH, TSCL) address and just to read the contents.

     

    Thanks

     

    Habdulgh

     

  • Habdulgh,

    I still don't know what device you are using.  You say it is not listed in the TMS family?  Then what device is it?

    If you need to measure elapsed time from your code, you have to access a timer in the device, start it, stop it, then read the count.

    Regards,

    David