4 * Simple benchmarking library
6 * $DragonFly: src/test/sysperf/blib.c,v 1.5 2006/04/22 22:32:52 dillon Exp $
15 static struct timeval tv1;
16 static struct timeval tv2;
21 gettimeofday(&tv1, NULL);
25 stop_timing(long long count, const char *ctl, ...)
30 gettimeofday(&tv2, NULL);
31 us = (tv2.tv_usec - tv1.tv_usec) + (tv2.tv_sec - tv1.tv_sec) * 1000000LL;
32 if (ctl == NULL) /* dummy call to pre-cache */
39 printf(" %6.3fs %lld loops = %6.3fuS/loop\n",
40 (double)us / 1000000.0,
42 (double)us / (double)count
48 stop_timing2(long long count, long long us, const char *ctl, ...)
56 printf(" %6.3fs %lld loops = %6.3fnS/loop\n",
57 (double)us / 1000000.0,
59 (double)us * 1000.0 / (double)count
69 gettimeofday(&tv2, NULL);
70 us = (tv2.tv_usec - tv1.tv_usec) + (tv2.tv_sec - tv1.tv_sec) * 1000000LL;