Altera_Forum
Honored Contributor
21 years agoPerformance Counter
I want to measure a time count taken for a section of a code. But the output i'm getting is always zero. I'm viewing my output through IDE output console.
I have patched my code and the output i got. Note: Using Quarus II 4.2 SP1 Can anyone help me in this regard. Thanks, Sanchu.C # #########################CODE##################### # include <stdio.h># include "altera_avalon_performance_counter.h"# include "system.h" void* perfbase = 0x00100800; # define COMPUTE_FUNCTION_SECTION 1 void compute() { int counter,sum; sum=0; PERF_BEGIN (perfbase, COMPUTE_FUNCTION_SECTION); for(counter=0;counter<100;counter++) sum=sum+counter; PERF_END (perfbase, COMPUTE_FUNCTION_SECTION); printf("\n Sum = %d \n",sum); } int main() { printf("Hello from Nios II!\n"); PERF_RESET (perfbase); PERF_START_MEASURING (perfbase); compute(); PERF_STOP_MEASURING (perfbase); unsigned int section_time = 1; section_time = perf_get_section_time (perfbase,COMPUTE_FUNCTION_SECTION); printf ("section_time: %d\n",section_time); perf_print_formatted_report(perfbase, ALT_CPU_FREQ,1,"compute"); return 0; } # ##################OUTPUT VIEW THROUGH IDE CONSOLE##################### Hello from Nios II! Sum = 4950 section_time: 0 --Performance Counter Report-- Total Time: 0 seconds (0 clock-cycles) +---------------+-----+-----------+---------------+-----------+ | Section | % | Time (sec)| Time (clocks)|Occurrences| +---------------+-----+-----------+---------------+-----------+ |compute | NaN| 0.00000| 0| 0| +---------------+-----+-----------+---------------+-----------+