Profiling Your Code
3-14
Count represents the number of times each function was called and entered.
Inclusive represents the total cycle time spent inside that function including
calls to other functions. Incl–Max (Inclusive Max) represents the longest time
spent inside that function during one call. Exclusive and Excl–Max are the
same as Inclusive and Incl–Max except that time spent in calls to other func-
tions inside that function have been removed.
3.3.1.2
Using the Clock( ) Function to Profile
To get cycle count information for a function or region of code with the standa-
lone simulator, embed the clock( ) function in your C code. The following exam-
ple demonstrates how to include the clock() function in your C code.
Example 3–5. Including the clock( ) Function
#include <stdio.h>
#include <time.h> /* need time.h in order to call clock()*/
main(int argc, char *argv[]) {
const short coefs[150];
short optr[150];
short state[2];
const short a[150];
const short b[150];
int c = 0;
int dotp[1] = {0};
int sum= 0;
short y[150];
short scalar = 3345;
const short x[150];
clock_t start, stop, overhead;
start = clock(); /* Calculate overhead of calling clock*/
stop = clock(); /* and subtract this value from The results*/
overhead = stop – start;
start = clock();
sum = mac1(a, b, c, dotp);
stop = clock();
printf(”mac1 cycles: %d\n”, stop – start – overhead);
start = clock();
vec_mpy1(y, x, scalar);
stop = clock();
printf(”vec_mpy1 cycles: %d\n”, stop – start – over head);
start = clock();
iir1(coefs, x, optr, state);
stop = clock();
printf(”iir1 cycles: %d\n”, stop – start – overhead);
}