[master] 4ec789a Add a trivial benchmark to the vtim test
Nils Goroll
nils.goroll at uplex.de
Fri Nov 4 08:12:05 CET 2016
commit 4ec789af6a6e8cadf3c81af1939834379949e835
Author: Nils Goroll <nils.goroll at uplex.de>
Date: Fri Nov 4 08:09:07 2016 +0100
Add a trivial benchmark to the vtim test
diff --git a/lib/libvarnish/vtim.c b/lib/libvarnish/vtim.c
index 509ba9a..cd8c2ae 100644
--- a/lib/libvarnish/vtim.c
+++ b/lib/libvarnish/vtim.c
@@ -466,6 +466,29 @@ tst_delta()
}
}
+static void
+bench()
+{
+ double s, e, t;
+ int i;
+
+ t = 0;
+ s = VTIM_real();
+ for (i=0; i<100000; i++)
+ t += VTIM_real();
+ e = VTIM_real();
+ printf("real: %fs / %d = %fns - tst val %f\n",
+ e - s, i, 1e9 * (e - s) / i, t);
+
+ t = 0;
+ s = VTIM_real();
+ for (i=0; i<100000; i++)
+ t += VTIM_mono();
+ e = VTIM_real();
+ printf("mono: %fs / %d = %fns - tst val %f\n",
+ e - s, i, 1e9 * (e - s) / i, t);
+}
+
int
main(int argc, char **argv)
{
@@ -478,6 +501,8 @@ main(int argc, char **argv)
AZ(setenv("TZ", "UTC", 1));
assert(sizeof t >= 8);
+ bench();
+
/* Brute force test against libc version */
for (t = -2209852800; t < 20000000000; t += 3599) {
gmtime_r(&t, &tm);
More information about the varnish-commit
mailing list