2 Copyright © 1997-98, The AROS Development Team. All rights reserved.
5 Desc: Demo of new OOP system
10 #include "timerclass.h"
20 extern struct OOPBase
*oopbase
;
24 #define NUM_ITERATIONS (10000000)
26 IPTR
TestFunc(Class
*cl
, Object
*o
, Msg msg
)
32 int main(int argc
, char **argv
)
39 printf("Object system initialized\n");
42 /* Initialize the timer class */
43 timercl
= MakeTimerClass();
50 printf("Class list:\n");
51 ForeachNode(&(oopbase
->ClassList
), n
)
53 printf("%s\n", n
->ln_Name
);
57 #if (HASHED_IFS || HASHED_METHODS)
59 printf("Hash table:\n");
60 for (i
= 0; i
< HashSize(timercl
->HashTable
); i
++)
64 for (b
= (struct Bucket
*)timercl
->HashTable
[i
]; b
; b
= b
->Next
)
65 printf (" %ld %p", b
->ID
, b
);
74 printf("Hash table:\n");
75 for (i
= 0; i
< HashSize(timercl
->HashTable
); i
++)
79 for (b
= (struct Bucket
*)timercl
->HashTable
[i
]; b
; b
= b
->Next
)
80 printf (" %s %p", (STRPTR
)b
->ID
, b
);
88 /* Create a new instance */
89 timer
= NewObject(NULL
, TIMERCLASS
, NULL
);
93 METHODID methodid
= M_Timer_TestMethod
;
95 printf("Timer object: %p\n", timer
);
97 printf ("Doing ten billion calls to test method...\n");
100 /* Normal ivocation test */
101 printf ("Using normal invocation\n");
105 for (i
= 0; i
< NUM_ITERATIONS
; i
++)
107 Timer_TestMethod(timer
);
111 printf("Time elapsed: ");
112 Timer_PrintElapsed(timer
);
116 printf("\nTen billion calls to empty *function*\n");
119 for (i
= 0; i
< NUM_ITERATIONS
; i
++)
121 TestFunc(timercl
, timer
, (Msg
)&methodid
);
126 printf("Time elapsed: ");
127 Timer_PrintElapsed(timer
);
132 printf("\nLooping ten billion times\n");
135 for (i
= 0; i
< NUM_ITERATIONS
; i
++)
142 printf("Time elapsed: ");
143 Timer_PrintElapsed(timer
);
145 printf("\n\nTestMethod output: %ld\n", Timer_TestMethod(timer
));
148 DisposeObject(timer
);
151 FreeTimerClass(timercl
);