- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I'm creating C++ Hello World executable project and replace the code with the one you stated. I'm getting the results for Nios II Eclipse IDE and Nios V RiscFree IDE as below:
Nios II Eclipse IDE (image):
Nios V RiscFree IDE (image):
Both are almost the same. RiscFree (42) seems like faster a bit than Eclipse (48). Check the attached file.
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi @Chris039 ,
Do you still need further help on this thread?
Let me know if you have further concern or consideration.
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yes. Let me check the file and I will update again .
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am not comparing the software tool. I was instantiating the Nios II processor and Nios V processor in Qsys, comparing both the time taken to execute the command.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
May be can refer to this link https://levelup.gitconnected.com/8-ways-to-measure-execution-time-in-c-c-48634458d0f9 on various ways of measuring cpu execution time. Or try to reprogram the software.
Thanks,
Best Regards,
Sheng
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
This is not related to reprogramming. Can you try to measure using the Nios V processor? You may generate the example design in https://www.intel.com/content/www/us/en/docs/programmable/726952/22-1-21-2-0/processor-example-design.html
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi @Chris039 ,
I have done testing Nios V Hello World Example Design. I'm measuring the time taken for Nios V to run C++ code with looper and usleep(1000000) (code image below) and getting the results (image below):
Time taken: 16771 clicks (0.016771s)
Then I'm measuring the time taken for Nios V to run with only usleep(1000000) without looper (code image below) and getting the results (image below):
Time taken: 994 clicks (0.000994s). Close to your results.
Installed RAM: 16.0 GB
I think the execution time measuring code and your result are both valid.
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Let me try to run.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi @Chris039 ,
Do you have any further update or concern?
Let me know if there's any.
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Sheng,
I tried running the second code that you have shared.
clock_t t;
t = clock();
printf ("Calculating...\n");
usleep(1000000);
printf ("Bye world...\n");
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);
Why is my value in the bracket has negative sign and different from yours?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If I would like to delay one second in the code? what is the value I should put in usleep ()?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Have you include the related library?
usleep() is in microseconds so you have to put 1000000 for 1 second.
Thanks,
Best Regards,
Sheng
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Do you have the compilation result with the code above using Nios II processor?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi @Chris039 ,
Still in the process of testing. Let me get back to you once getting the testing result.
Thanks,
Best Regards,
Sheng
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page