[6.0] f9b5e83e1 add phk's suggestion to the micro-benchmark
Dridi Boukelmoune
dridi.boukelmoune at gmail.com
Wed Oct 31 13:08:28 UTC 2018
commit f9b5e83e19621c4eb5032f4773ab3fbd3e2e6571
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