- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi
I try to check the execution time of my algorithme. I use the high res_timer. I find on the tutorial how can calculate it, at least with this instruction: time1= alt_timestamp(); K=1; time2= alt_timestamp(); num_ticks=time2-time1; printf("execution time en ms is : %.*f (ms)\n",4, (((float)num_ticks/(float)alt_timestamp_freq())*(float)1000)); And when i try to calculate the execution time for just simple instruction (k=1) i don't find one clock cycle. The frequency that i use is 250 Mhz. It mean that for execute (k=1) instruction should be 0.004 microsecond but i find 0.4 microsecond. That's mean there are a factor of 100. My question is there are mistake on the method? Or i should devide the time by 100? Or what is the problem? Thank youLink Copied
4 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Throwing time snapshots around a single instruction isn't going to yield any answer besides 0. The timer resolution isn't fine grain enough to count clock cycles. Typically you measure the time for a criticial section of code and if that's too short you throw it into a loop to measure an average time per loop iteration.
You could create a timer core with a resolution of a clock cycle to measure something like k=1; but to be honest it doesn't seem like something worth doing..... if you want to debug your measuring technique why not just put a usleep() call in there for a significant amount of time and see if the measured value is in the same ballpark as the sleep time you passed into usleep()?- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you for your reply, ok i will check you method and inform you.
Thanks- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
--- Quote Start --- Throwing time snapshots around a single instruction isn't going to yield any answer besides 0. The timer resolution isn't fine grain enough to count clock cycles. Typically you measure the time for a criticial section of code and if that's too short you throw it into a loop to measure an average time per loop iteration. You could create a timer core with a resolution of a clock cycle to measure something like k=1; but to be honest it doesn't seem like something worth doing..... if you want to debug your measuring technique why not just put a usleep() call in there for a significant amount of time and see if the measured value is in the same ballpark as the sleep time you passed into usleep()? --- Quote End --- Ok your idea it is very good. I use usleep and the method that i mentionned give a good result. THank you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
When measuring instruction performance a simulation is probably the most appropriate way to determine the time. The cycle counts for the Nios II processor are documented in the hardware handbook so if that's all you were looking to do then I would just look them up.
If you plan on measuring critical sections of code and want more timer resolution then I would take a look at the performance counter component. It'll measure a few criticial sections with clock cycle resolution.
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page