cpu time of the computation

Hi,

I am new in using the embeded device (VirtexII-Pro) to implement an algorithm. As I want to count the cpu time of the algorithm , I use the XTime_GetTime(starttime) in the the xtime_l.h library. Also I need to print out the result to a uart by using xil_printf. But the result did not displayed successfully. Please find the program as follows.

Is there any step missed?

Many thanks, Terrence

#include "xgpio.h" #include "xparameters.h" #include "math.h" #include "xtime_l.h"

main() { XGpio gpio_reset, gpio_addr, gpio_data; int i,j=0, count=0,k, site=0; double likelihood[12], probability=0.0, lnL=0.0; XTime *starttime, *endtime; char *output;

xil_printf("start\n"); XTime_GetTime(starttime);

// Start computation

...

//End computation

XTime_GetTime(endtime);

//convert the long long to a string sprintf(output, "%llu", *endtime);

//print the result while(*output){ xil_printf("%c", *output); ++output; }

}
Reply to
Terrence Mak
Loading thread data ...

The following statements only allocate pointers, not a memory array or structure pointed to. I'm not sure if the XTime_GetTime() function allocates memory for you, but I'm sure than sprintf does not.

Thus you're calling functions with uninitialized pointers and the result is stored (probably at location zero) where the pointers were at the time of call.

if XTime starttime, endtime; char output[16]; // or as large as the largest message

xil_printf("start\n"); XTime_GetTime(&starttime);

// Start computation

...

//End computation

XTime_GetTime(&endtime);

//convert the long long to a string sprintf(output, "%llu", endtime);

...

you should have better results

Reply to
Gabor Szakacs

It works, Thanks!

Terrence

the

Reply to
Terrence Mak

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.