ipfw3: remove legacy macros
[dragonfly.git] / test / sysperf / cmp.c
blob21df2f78892010bb9ae1e676b1f4ed954a6acd38
1 /*
2 * cmp.c
4 * Test for comparing pointers vs bit-testing.
6 * $DragonFly: src/test/sysperf/cmp.c,v 1.1 2005/08/03 13:37:27 hmp Exp $
7 */
9 #include "blib.h"
11 #define LOOP 1000000000
13 static void nop(void) { }
15 struct f {
16 void (*nop_ptr)(void);
17 int mask;
18 } foo;
19 #define SOME_MASK 0x00800
21 struct f *fp = &foo;
23 int
24 main(int ac, char **av)
26 int i;
27 struct f *fp = &foo;
28 foo.nop_ptr = nop;
29 foo.mask = SOME_MASK;
31 printf("compare nop() function pointer against NULL (struct not pointer)\n");
32 start_timing();
33 for (i = 0; i < LOOP; ++i)
34 if (foo.nop_ptr == NULL)
36 stop_timing(LOOP, "loop1/cmp-pointer");
38 printf("compare nop() function pointer against NULL (struct pointer)\n");
39 start_timing();
40 for (i = 0; i < LOOP; ++i)
41 if (fp->nop_ptr == NULL)
43 stop_timing(LOOP, "loop2/cmp-pointer");
45 printf("compare bitmask checking\n");
46 start_timing();
47 for (i = 0; i < LOOP; ++i)
48 if (foo.mask & SOME_MASK)
50 stop_timing(LOOP, "loop3/cmp-bitmask");
53 return(0);