X-Git-Url: https://git.cworth.org/git?p=fips;a=blobdiff_plain;f=metrics.c;h=64f1dccd1af331a4d9eeece75362a96ac54a5023;hp=1e2e0184e6592af840c4a69eff7247a004e49c26;hb=2926b5a9207c28986f449a322761e4103f4c28e7;hpb=4fba48e967e0ab9d3af0bc230d1a0390250a5758 diff --git a/metrics.c b/metrics.c index 1e2e018..64f1dcc 100644 --- a/metrics.c +++ b/metrics.c @@ -391,13 +391,49 @@ time_compare(const void *in_a, const void *in_b, void *arg) return 0; } +static void +print_op_metrics (op_metrics_t *metric, double total) +{ + const char *op_string; + unsigned i; + + /* Since we sparsely fill the array based on program + * id, many "programs" have no time. + */ + if (metric->time_ns == 0.0) + return; + + op_string = metrics_op_string (metric->op); + + printf ("%s", op_string); + if (metric->op >= METRICS_OP_SHADER) { + printf (" %d:", metric->op - METRICS_OP_SHADER); + } else { + printf (":"); + for (i = strlen (op_string); i < 20; i++) + printf (" "); + } + + printf ("\t%7.2f ms (% 2.1f%%)", + metric->time_ns / 1e6, + metric->time_ns / total * 100); + + printf ("["); + for (i = 0; i < metric->num_counters; i++) { + if (metric->counters[i] == 0.0) + continue; + printf ("%d: %.2f ms ", i, metric->counters[i] / 1e6); + } + printf ("]\n"); +} + static void print_program_metrics (void) { context_t *ctx = ¤t_context; int *sorted; /* Sorted indices into the ctx->op_metrics */ double total = 0; - unsigned i, j; + unsigned i; /* Make a sorted list of the operations by time used, and figure * out the total so we can print percentages. @@ -410,37 +446,8 @@ print_program_metrics (void) qsort_r(sorted, ctx->num_op_metrics, sizeof(*sorted), time_compare, ctx->op_metrics); - for (i = 0; i < ctx->num_op_metrics; i++) { - const char *op_string; - op_metrics_t *metric =&ctx->op_metrics[sorted[i]]; - - /* Since we sparsely fill the array based on program - * id, many "programs" have no time. - */ - if (metric->time_ns == 0.0) - continue; - - op_string = metrics_op_string (metric->op); - - printf ("%s", op_string); - if (metric->op >= METRICS_OP_SHADER) { - printf (" %d:", metric->op - METRICS_OP_SHADER); - } else { - printf (":"); - for (j = strlen (op_string); j < 20; j++) - printf (" "); - } - printf ("\t%7.2f ms (% 2.1f%%)", - metric->time_ns / 1e6, - metric->time_ns / total * 100); - printf ("["); - for (j = 0; j < metric->num_counters; j++) { - if (metric->counters[j] == 0.0) - continue; - printf ("%d: %.2f ms ", j, metric->counters[j] / 1e6); - } - printf ("]\n"); - } + for (i = 0; i < ctx->num_op_metrics; i++) + print_op_metrics (&ctx->op_metrics[sorted[i]], total); } /* Called at program exit */