cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Observer
Observer
726 Views
Registered: ‎04-05-2018

execution time of c code

Hello,

 

Currently i am working on Zygo(Zync702) board and i want to find the time taken by print function to put strings on Uart terminal, in my c code. Is there any way like SysTick timer of ARM Processor to find the time taken by a set of C code?

Basically i want to know the execution time of instructions.

 

Thanks in advance.

0 Kudos
2 Replies
Highlighted
Moderator
Moderator
648 Views
Registered: ‎07-31-2012

Re: execution time of c code

Hi @creative1,

 

If you want to calculate the time taken to execute a piece of code, have to included timers in the hardware design.

Later at software application below reference will help you to do calculate the execution time.

You can use the following template:

 

#include xtime_l.h

 

Xtime tStart, tEnd;

Xtime_GetTime(&tStart);

 

Xtime_GetTime(&tEnd);

 

Printf("Output took %llu clock cycles. \n", 2*(tEnd-tStart));

ElapsedTime=1.0*(tEnd-tStart)/(COUNTS_PER_SECOND);

Printf("Output took %.2f s.\n",ElapsedTime);

 

Regards

Praveen


-------------------------------------------------------------------------
Don’t forget to reply, kudo, and accept as solution.
-------------------------------------------------------------------------
0 Kudos
Highlighted
Observer
Observer
644 Views
Registered: ‎04-05-2018

Re: execution time of c code

hi ,

yes this can be done. I wonder if i could have used arm's systick timer.

 

Anyway thank you for the reply:)

0 Kudos