Resync patch with contrib.
[dragonfly.git] / test / sysperf / call3.c
blob685b4c96e4d2d498f654dc483b2afc5445a9b0ca
1 /*
2 * call3.c
4 * Test a standard function call to a function which does nothing much.
6 * $DragonFly: src/test/sysperf/call3.c,v 1.3 2005/08/02 17:11:04 hmp Exp $
7 */
9 #include "blib.h"
11 #define LOOP 500000000
13 __asm(".p2align 6");
14 static void nop1(void) { }
15 __asm(".p2align 6");
16 static void nop2(void) { }
17 __asm(".p2align 6");
18 static void nop(void (*func)(void)) { func(); }
20 int
21 main(int ac, char **av)
23 int i;
25 printf("call nop() function through function pointer in loop\n");
26 start_timing();
27 for (i = 0; i < LOOP; ++i) {
28 nop(nop1);
29 nop(nop1);
31 stop_timing(LOOP * 2, "call3/nop1-1");
32 start_timing();
33 for (i = 0; i < LOOP; ++i) {
34 nop(nop1);
35 nop(nop2);
37 stop_timing(LOOP * 2, "call3/nop1-2");
38 start_timing();
39 for (i = 0; i < LOOP; ++i) {
40 nop(nop2);
41 nop(nop2);
43 stop_timing(LOOP * 2, "call3/nop2-2");
44 return(0);