+ int *sorted; /* Sorted indices into the ctx->program_metrics */
+ double total = 0;
+
+ /* Make a sorted list of the programs by time used, and figure
+ * out to total so we can print percentages.
+ */
+ sorted = calloc(ctx->num_program_metrics, sizeof(*sorted));
+ for (i = 0; i < ctx->num_program_metrics; i++) {
+ sorted[i] = i;
+ total += ctx->program_metrics[i].ticks;
+ }
+ qsort_r(sorted, ctx->num_program_metrics, sizeof(*sorted),
+ time_compare, ctx->program_metrics);