add printing of region table
This commit is contained in:
parent
1437339a1c
commit
ff290e1fad
|
@ -56,6 +56,56 @@ rvprof_error_t rvprof_output_generate_report(void){
|
|||
|
||||
// use stdlib's quicksort to sort functions by elapsed time
|
||||
qsort(g_rvprof.functions.data, g_rvprof.functions.size, sizeof(function_stats_t), compare_functions);
|
||||
|
||||
// write region table
|
||||
fprintf(g_rvprof.output_file, "RVProf Runtime Profile\n");
|
||||
fprintf(g_rvprof.output_file, "+-------+-----------+-----------+-----------+-----------+---------------+---------------+---------------------------------------------+---------------------------------------------+------+\n");
|
||||
fprintf(g_rvprof.output_file, "| Calls | t_excl[s] | t_excl[%%] | t_incl[s] | t_incl[%%] | excl_cycles | incl_cycles | Function | Caller | STID |\n");
|
||||
fprintf(g_rvprof.output_file, "+-------+-----------+-----------+-----------+-----------+---------------+---------------+---------------------------------------------+---------------------------------------------+------+\n");
|
||||
|
||||
// add region data
|
||||
for (int i = 0; i < g_rvprof.functions.size; i++) {
|
||||
function_stats_t* stats = &g_rvprof.functions.data[i];
|
||||
double excl_sec = rvprof_timing_to_seconds(stats->total_exclusive_time);
|
||||
double incl_sec = rvprof_timing_to_seconds(stats->total_inclusive_time);
|
||||
|
||||
// use first stack ID for display
|
||||
int display_stid = (stats->num_stack_ids > 0) ? stats->stack_ids[0] : 0;
|
||||
|
||||
// truncate function name if too long
|
||||
char truncated_function[44];
|
||||
if (strlen(stats->name) > 43) {
|
||||
strncpy(truncated_function, stats->name, 40);
|
||||
strcpy(truncated_function + 40, "...");
|
||||
} else {
|
||||
strcpy(truncated_function, stats->name);
|
||||
}
|
||||
|
||||
// truncate caller name if too long
|
||||
char truncated_caller[44];
|
||||
if (strlen(stats->caller) > 43) {
|
||||
strncpy(truncated_caller, stats->caller, 40);
|
||||
strcpy(truncated_caller + 40, "...");
|
||||
} else {
|
||||
strcpy(truncated_caller, stats->caller);
|
||||
}
|
||||
|
||||
fprintf(g_rvprof.output_file, "|%6lu |%10.3f |%10.1f |%10.3f |%10.1f |%14llu |%14llu | %-43s | %-43s |%5d |\n",
|
||||
stats->call_count,
|
||||
excl_sec,
|
||||
stats->exclusive_percent,
|
||||
incl_sec,
|
||||
stats->inclusive_percent,
|
||||
(unsigned long long)stats->total_exclusive_cycles,
|
||||
(unsigned long long)stats->total_inclusive_cycles,
|
||||
truncated_function,
|
||||
truncated_caller,
|
||||
display_stid);
|
||||
}
|
||||
fprintf(g_rvprof.output_file, "+-------+-----------+-----------+-----------+-----------+---------------+---------------+---------------------------------------------+---------------------------------------------+------+\n");
|
||||
fprintf(g_rvprof.output_file, "\n");
|
||||
|
||||
|
||||
|
||||
return RVPROF_SUCCESS;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue