2 Copyright © 1997-98, The AROS Development Team. All rights reserved.
5 Desc: Demo of new OOP system
10 #include "timerclass.h"
15 extern struct List ClassList
;
18 #define NUM_ITERATIONS (10000000)
20 IPTR
TestFunc(Class
*cl
, Object
*o
, Msg msg
)
26 int main(int argc
, char **argv
)
33 printf("Object system initialized\n");
36 /* Initialize the timer class */
37 timercl
= MakeTimerClass();
44 printf("Class list:\n");
45 ForeachNode(&ClassList
, n
)
47 printf("%s\n", n
->ln_Name
);
51 printf("Hash table:\n");
53 /* Create a new instance */
54 timer
= NewObject(NULL
, TIMERCLASS
, NULL
);
58 ULONG methodid
= M_Timer_TestMethod
;
60 printf("Timer object: %p\n", timer
);
62 printf ("Doing ten billion calls to test method...\n");
65 /* Normal ivocation test */
66 printf ("Using normal invocation\n");
70 for (i
= 0; i
< NUM_ITERATIONS
; i
++)
72 Timer_TestMethod(timer
);
76 printf("Time elapsed: ");
77 Timer_PrintElapsed(timer
);
81 printf("\nTen billion calls to empty *function*\n");
84 for (i
= 0; i
< NUM_ITERATIONS
; i
++)
86 TestFunc(timercl
, timer
, (Msg
)&methodid
);
91 printf("Time elapsed: ");
92 Timer_PrintElapsed(timer
);
97 printf("\nLooping ten billion times\n");
100 for (i
= 0; i
< NUM_ITERATIONS
; i
++)
107 printf("Time elapsed: ");
108 Timer_PrintElapsed(timer
);
110 printf("\n\nTestMethod output: %ld\n", Timer_TestMethod(timer
));
113 DisposeObject(timer
);
116 FreeTimerClass(timercl
);