- if (rd->f&TVRF_ID) {
- if (f&f_any) tvec_write(tv, ", ");
- else f |= f_any;
- tvec_write(tv, "%s = ", rd->name);
- rd->ty->dump(&TVEC_REG(tv, in, rd->i)->v, rd, tv, TVSF_COMPACT);
- }
-
-#undef f_any
-}
-
-static void normalize(double *x_inout, const char **unit_out, double scale)
-{
- static const char
- *const nothing = "",
- *const big[] = { "k", "M", "G", "T", "P", "E", 0 },
- *const little[] = { "m", "ยต", "n", "p", "f", "a", 0 };
- const char *const *u;
- double x = *x_inout;
-
- if (x < 1)
- for (u = little, x *= scale; x < 1 && u[1]; u++, x *= scale);
- else if (x >= scale)
- for (u = big, x /= scale; x >= scale && u[1]; u++, x /= scale);
- else
- u = ¬hing;
-
- *x_inout = x; *unit_out = *u;
-}
-
-static void bench_report(struct tvec_state *tv,
- const struct bench_timing *tm)
-{
- const struct tvec_bench *b = tv->test->arg.p;
- double n = (double)tm->n*b->niter;
- double x, scale;
- const char *u, *what, *whats;
-
- assert(tm->f&BTF_TIMEOK);
-
- if (b->rbuf == -1) {
- tvec_write(tv, " -- %.0f iterations ", n);
- what = "op"; whats = "ops"; scale = 1000;
- } else {
- n *= TVEC_REG(tv, in, b->rbuf)->v.bytes.sz;
- x = n; normalize(&x, &u, 1024); tvec_write(tv, " -- %.3f %sB ", x, u);
- what = whats = "B"; scale = 1024;
- }
- x = tm->t; normalize(&x, &u, 1000);
- tvec_write(tv, "in %.3f %ss", x, u);
- if (tm->f&BTF_CYOK) {
- x = tm->cy; normalize(&x, &u, 1000);
- tvec_write(tv, " (%.3f %scy)", x, u);
- }
- tvec_write(tv, ": ");
-
- x = n/tm->t; normalize(&x, &u, scale);
- tvec_write(tv, "%.3f %s%s/s", x, u, whats);
- x = tm->t/n; normalize(&x, &u, 1000);
- tvec_write(tv, ", %.3f %ss/%s", x, u, what);
- if (tm->f&BTF_CYOK) {
- x = tm->cy/n; normalize(&x, &u, 1000);
- tvec_write(tv, " (%.3f %scy/%s)", x, u, what);
- }
- tvec_write(tv, "\n");