+ sorted[i] = i;
+ total += ctx->program_metrics[i].time_ns;
+ }
+ qsort_r(sorted, ctx->num_program_metrics, sizeof(*sorted),
+ time_compare, ctx->program_metrics);
+
+ for (i = 0; i < ctx->num_program_metrics; i++) {
+ struct program_metrics *metric =
+ &ctx->program_metrics[sorted[i]];
+
+ /* Since we sparsely fill the array based on program
+ * id, many "programs" have no time.
+ */
+ if (metric->time_ns == 0.0)