[master] a289b6191 add phk's suggestion to the micro-benchmark

Nils Goroll nils.goroll at uplex.de
Mon Oct 8 08:30:09 UTC 2018


commit a289b619179135b2779b926378bc4558c7fe9e48
Author: Nils Goroll <nils.goroll at uplex.de>
Date:   Mon Oct 8 10:29:29 2018 +0200

    add phk's suggestion to the micro-benchmark

diff --git a/lib/libvarnish/vtim.c b/lib/libvarnish/vtim.c
index 5c6503c7e..822f522d2 100644
--- a/lib/libvarnish/vtim.c
+++ b/lib/libvarnish/vtim.c
@@ -537,9 +537,20 @@ bench()
 		t += buf[4];
 	}
 	e = VTIM_mono();
-	printf("%s\n", buf);
-	printf("printf: %fs / %d = %fns - tst val %f\n",
-	    e - s, i, 1e9 * (e - s) / i, t);
+	printf("printf %%.6f: %fs / %d = %fns - tst val %f %s\n",
+	    e - s, i, 1e9 * (e - s) / i, t, buf);
+
+	t = 0;
+	s = VTIM_mono();
+	for (i=0; i<100000; i++) {
+		snprintf(buf, sizeof(buf), "%ju.%06ju",
+			 (uint64_t)floor(s),
+			 (uint64_t)floor((s * 1e6)) % 1000000UL);
+		t += buf[4];
+	}
+	e = VTIM_mono();
+	printf("printf %%ju.%%06ju: %fs / %d = %fns - tst val %f %s\n",
+	    e - s, i, 1e9 * (e - s) / i, t, buf);
 }
 
 void


More information about the varnish-commit mailing list