Convert assembly which accesses segment descriptors to use 16bit ops.
[dragonfly.git] / test / sysperf / blib.c
blobd8419d1572da2fc66ca06737b048abc5964b5494
1 /*
2 * BLIB.C
4 * Simple benchmarking library
6 * $DragonFly: src/test/sysperf/blib.c,v 1.5 2006/04/22 22:32:52 dillon 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 vprintf(ctl, va);
37 va_end(va);
39 printf(" %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 vprintf(ctl, va);
54 va_end(va);
56 printf(" %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)