Sync zoneinfo database with tzdata2009c from elsie.
[dragonfly.git] / test / sysperf / blib.c
blobcf09cad4d1e221bc67dc7b00a75cc2d4ac8c1d6c
1 /*
2 * BLIB.C
4 * Simple benchmarking library
6 * $DragonFly: src/test/sysperf/blib.c,v 1.6 2007/08/21 19:23:46 corecode Exp $
7 */
9 #include <sys/types.h>
10 #include <sys/time.h>
11 #include <stdio.h>
12 #include <stdlib.h>
13 #include <stdarg.h>
15 static struct timeval tv1;
16 static struct timeval tv2;
18 void
19 start_timing(void)
21 gettimeofday(&tv1, NULL);
24 int
25 stop_timing(long long count, const char *ctl, ...)
27 long long us;
28 va_list va;
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 */
33 return(us > 1000000);
35 va_start(va, ctl);
36 vfprintf(stderr, ctl, va);
37 va_end(va);
39 fprintf(stderr, " %6.3fs %lld loops = %6.3fuS/loop\n",
40 (double)us / 1000000.0,
41 count,
42 (double)us / (double)count
44 return(0);
47 int
48 stop_timing2(long long count, long long us, const char *ctl, ...)
50 va_list va;
52 va_start(va, ctl);
53 vfprintf(stderr, ctl, va);
54 va_end(va);
56 fprintf(stderr, " %6.3fs %lld loops = %6.3fnS/loop\n",
57 (double)us / 1000000.0,
58 count,
59 (double)us * 1000.0 / (double)count
61 return(0);
64 long long
65 get_timing(void)
67 long long us;
69 gettimeofday(&tv2, NULL);
70 us = (tv2.tv_usec - tv1.tv_usec) + (tv2.tv_sec - tv1.tv_sec) * 1000000LL;
71 return(us);
74 void
75 nop(void)