Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Valued Contributor III
1,128 Views

Using Timestamp to measure code execution time

I'm trying to measure the time taken in seconds for a section of my c-code to execute. I've followed the instructions from the Nios handbook - Chapter 6 - Example 6-9 as below 

 

if (alt_timestamp_start()< 0) { printf ("No timestamp device is available.\n"); } time1 = alt_timestamp(); func(); //function being monitored time2 = alt_timestamp(); printf("timestamp value = %u ticks\n", (unsigned int) (time2 - time1));  

 

If I want to get the actual time taken in seconds, do I just divide the timestamp value by alt_timestamp_freq()?  

 

I have added the Interval Timer component in SOPC with default parameters. How do these parameters affect my actual time? I read the 'Interval Timer Core' documentation but I am not sure if I have to change any setting for my usage.
0 Kudos
2 Replies
Highlighted
Valued Contributor III
8 Views

OK, I found what I was looking for. Please ignore post above. Sorry.

0 Kudos
Highlighted
Valued Contributor III
8 Views

Could you please show me how to use it to calculate the performance of C code run on Nios ? 

 

Thanks, 

Khai.
0 Kudos