Baremetal app time measurement using HWlib seems not accurate
Hi,
I'm using the Intel HWlib for measuring some steps execution time on the Arrive V SoC HPS (Arm CPU).
The problem is that I'm suspecting for getting unrealistic results.
The code is as follows:
1. /* Initialize and start timer (counter) for 9 seconds */
socfpga_timer_start(ALT_GPT_CPU_PRIVATE_TMR, 9000);
2. 10 Iterations loop:
2.1. /* get current counter value */
counter_val = alt_gpt_counter_get(ALT_GPT_CPU_PRIVATE_TMR);
2.2. /* 1 second delay */
alt_gpt_delay_ns(ALT_GPT_CPU_PRIVATE_TMR, counter_val, 1000000000)
2.3. /* start measure time */
start_time = alt_gpt_curtime_microsecs_get(ALT_GPT_CPU_PRIVATE_TMR);
2.4. /* perform step1 calculations */
.
.
2.5 /* stop measure time */
end_time = alt_gpt_curtime_microsecs_get(ALT_GPT_CPU_PRIVATE_TMR);
2.6. /* calculate step 1 execution time */
printf("\n elapsed time = %" PRIu32 "microsec\n" , t_start-t_end);
3.1. /* start measure time */
start_time = alt_gpt_curtime_microsecs_get(ALT_GPT_CPU_PRIVATE_TMR);
3.2. /* perform step2 calculations */
.
.
3.3 /* stop measure time */
end_time = alt_gpt_curtime_microsecs_get(ALT_GPT_CPU_PRIVATE_TMR);
3.4. /* calculate step 2 execution time */
printf("\n elapsed time = %" PRIu32 "microsec\n" , t_start-t_end);
* The counter doesn't reach 0 during these measurments *
I fear that I'm getting too long results for each measurement. Is there something wrong with my code?
Thanks
Hi bsp_user
Sorry for the confusion.
I thought you were implying that the api are not returning an inaccurate results.
Yeah. The usage of the API are correct.
Regards
Jingyang, Teh