Programmable Devices
CPLDs, FPGAs, SoC FPGAs, Configuration, and Transceivers
20677 Discussions

Using Timestamp to measure code execution time

Altera_Forum
Honored Contributor II
1,516 Views

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
Altera_Forum
Honored Contributor II
396 Views

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

0 Kudos
Altera_Forum
Honored Contributor II
396 Views

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

 

Thanks, 

Khai.
0 Kudos
Reply