Forum Discussion
How to calculate the time for running the code in Nios II and Nios V?
Hi,
How do I calculate the time used for executing a command in Nios II and Nios V.
I was using the example in the below link but the results from Nios II and Nios V are different.
https://cplusplus.com/reference/ctime/clock/
-------------------------------------------------------------------------------------------------------
clock_t t;
t = clock();
printf ("Calculating...\n");
... (Anything, or you may put usleep (1000000)
...
...
t = clock() - t;
printf ("It took me %ld clicks (%f seconds).\n",t,((float)t)/1000000);
printf ("It took me %u clicks (%x seconds).\n",t,((float)t)/1000000);
-------------------------------------------------------------------------------------------------------
Nios II
Nios V
Could you share the way to calculate the time taken for running a piece of code in Nios V?
Thanks
17 Replies
- Chris039
Occasional Contributor
Do you have the compilation result with the code above using Nios II processor?
- Chris039
Occasional Contributor
@ShengN_Intel Any updates from your side?
- ShengN_altera
Super Contributor
Hi @Chris039 ,
Still in the process of testing. Let me get back to you once getting the testing result.
Thanks,
Best Regards,
Sheng
- ShengN_altera
Super Contributor
Hi @Chris039 ,
I tested the MAX 10 Nios II Hello World example in Intel FPGA Design Store. I found out for Nios II Interval Timer needs to be added in order to get accurate and valid execution time calculation. Also in BSP Editor, set the sys_clk_timer check image below:
The execution time of Nios II for running code without looper is 1427 clicks which is close to Nios V execution time of 997 clicks.
Folder attached below.
Thanks,
Best regards,
Sheng
p/s: If any answer from the community or Intel Support are helpful, please feel free to give best answer or rate 4/5 survey.
- ShengN_altera
Super Contributor
Hi @Chris039 ,
Do you have any further concern?
Thanks,
Best Regards,
Sheng
p/s: If any answer from the community or Intel Support are helpful, please feel free to give best answer or rate 4/5 survey.