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.

Profiling code on TMS320DM642 (500MHz)

Other Parts Discussed in Thread: TMS320DM642

Hello,

What is the correct procedure for profiling code on TMS320DM642 (500MHz) ? I am interested in getting an idea as to how much CPU time the algorithm requires.

It doesn't have to be super accurate. Right now I have an algorithm which is being called periodically. Interrupt is disabled. Code is optimized (-O3).

I call the algorithm with 10ms data (160 samples sampled at 16kHz) and measure the time before and after the call:

GetMicroSeconds(START, &ulStart);
Algorithm();
t1 = GetMicroSeconds(STOP, &ulStart);
printf ("Elapsed time: %d microseconds", (uint16)t1, 0);

I get close to 9500 microseconds which is close to 10milliseconds. Is that the same as saying that the algorithm takes close to 100% of the CPU? Or is that a conclusion made on false premises? Basically, I am just interested in how to measure the amount of CPU time the algorithm will require. On other (slower) non-TI platforms the algorithm has shown to take between 20-30% of the CPU time. So I'm a bit baffled by the high CPU time on this platform.

CODE SNIPPETS

uint32 GetMicroSeconds(uint16 cmd, uint32 *pCtx)
{
uint32 tStop=0;
uint32 nTick, nUsec=0;
uint32 ulCounterTick = COUNTER_TICK;

if (cmd == START)
{
*pCtx = GetHighResTime();
}
else if (cmd == STOP)
{
tStop = GetHighResTime();

if (*pCtx > tStop)
{
// Wrap around
nTick = (MAX32 - *pCtx) + tStop;
}
else
{
nTick = tStop - *pCtx;
}
// Convert to microseconds

nUsec = nTick / ulCounterTick;
}

return (nUsec);
}

uint32 GetHighResTime(void)
{
   uint40 timevalue;
   timevalue = CLK_gethtime();
   return (uint32)timevalue;
}