* Arguments: @const struct gprintf_ops *gops@ = print operations
* @void *go@ = print destination
* @unsigned unit@ = the unit being measured (~TVBU_...@)
+ * @unsigned style@ = output style (@TVSF_...@)
* @const struct bench_timing *tm@ = the benchmark result
*
* Returns: ---
*/
void tvec_benchreport(const struct gprintf_ops *gops, void *go,
- unsigned unit, const struct bench_timing *tm)
+ unsigned unit, unsigned style,
+ const struct bench_timing *tm)
{
double scale, x, n = tm->n;
const char *u, *what, *whats;
- if (!tm) { gprintf(gops, go, "benchmark FAILED"); return; }
+ if (!tm) {
+ if (style&TVSF_RAW) gprintf(gops, go, "FAILED");
+ else gprintf(gops, go, "benchmark FAILED");
+ return;
+ }
assert(tm->f&BTF_TIMEOK);
switch (unit) {
case TVBU_OP:
- gprintf(gops, go, "%.0f iterations ", n);
+ if (style&TVSF_RAW) gprintf(gops, go, "ops=%.0f", n);
+ else gprintf(gops, go, "%.0f iterations ", n);
what = "op"; whats = "ops"; scale = 1000;
break;
case TVBU_BYTE:
- x = n; normalize(&x, &u, 1024); gprintf(gops, go, "%.3f %sB ", x, u);
+ if (style&TVSF_RAW)
+ gprintf(gops, go, "bytes=%.0f", n);
+ else {
+ x = n;
+ normalize(&x, &u, 1024); gprintf(gops, go, " %.3f %sB ", x, u);
+ }
what = whats = "B"; scale = 1024;
break;
default:
abort();
}
+ if (style&TVSF_RAW) {
+ gprintf(gops, go, " sec=%.6g", tm->t);
+ if (tm->f&BTF_CYOK) gprintf(gops, go, " cy=%.0f", tm->cy);
+ return;
+ }
+
x = tm->t; normalize(&x, &u, 1000);
gprintf(gops, go, "in %.3f %ss", x, u);
if (tm->f&BTF_CYOK) {