Greetings
I am using CCS 3.3 and c6455 running at 1GHz. I am employing the TSCL registers to measure the time it takes (in terms of number of cycles) to execute a function.
My code is as follows:
#include <c6x.h>
...
maxiters = 50;
for (j=0;j<maxiters;j++)
{
start = TSCL;
stop = TSCL;
overhead = stop-start;
start_count = TSCL;
my_function;
stop_count = TSCL;
count_time = stop_count-start_count;
printf("Execution time = %d ns\n",count_time-overhead);
}
...
When running the code, the Execution time for "my_function" reported varies significantly between approximately 100,000 cycles and 511,000,000 cycles. On the contrary, the overhead is always the same and equal to 4 cycles.
Any ideas what could cause this variation? It is quite a complicated function but I don't see why the variation should vary this greatly.
Even better, is there an alternative, more accurate way of measuring the time it takes to execute a function?
Many thanks in advance
Ry