2 Copyright © 1997-98, The AROS Development Team. All rights reserved.
5 Desc: Demo of new OOP system
10 #include "timerclass.h"
16 extern struct List ClassList
;
19 #define NUM_ITERATIONS (10000000)
21 IPTR
TestFunc(Class
*cl
, Object
*o
, Msg msg
)
27 int main(int argc
, char **argv
)
34 printf("Object system initialized\n");
37 /* Initialize the timer class */
38 timercl
= MakeTimerClass();
46 printf("Class list:\n");
47 ForeachNode(&ClassList
, n
)
49 printf("%s\n", n
->ln_Name
);
53 printf("Hash table:\n");
55 for (i
= 0; i
< timercl
->HashTableSize
; i
++)
60 for (b
= timercl
->HashTable
[i
]; b
; b
= b
->Next
)
63 ,b
->mClass
->ClassNode
.ln_Name
72 /* Create a new instance */
73 timer
= NewObject(NULL
, TIMERCLASS
, NULL
);
77 ULONG methodid
= M_Timer_TestMethod
;
79 printf("Timer object: %p\n", timer
);
81 printf ("Doing ten billion calls to test method...\n");
84 /* Normal ivocation test */
85 printf ("Using normal invocation\n");
89 for (i
= 0; i
< NUM_ITERATIONS
; i
++)
91 Timer_TestMethod(timer
);
95 printf("Time elapsed: ");
96 Timer_PrintElapsed(timer
);
99 /* Fast ivocation test */
103 printf ("\nUsing fast invocation\n");
105 GetMethod(timer
, M_Timer_TestMethod
, &method
, &cl
);
109 for (i
= 0; i
< NUM_ITERATIONS
; i
++)
111 method(cl
, timer
, (Msg
)&methodid
);
115 printf("Time elapsed: ");
116 Timer_PrintElapsed(timer
);
118 printf("Method output: %ld\n", method(cl
, timer
, (Msg
)&methodid
));
121 printf("\nTen billion calls to empty *function*\n");
124 for (i
= 0; i
< NUM_ITERATIONS
; i
++)
126 TestFunc(timercl
, timer
, (Msg
)&methodid
);
131 printf("Time elapsed: ");
132 Timer_PrintElapsed(timer
);
137 printf("\nLooping ten billion times\n");
140 for (i
= 0; i
< NUM_ITERATIONS
; i
++)
147 printf("Time elapsed: ");
148 Timer_PrintElapsed(timer
);
150 printf("\n\nTestMethod output: %ld\n", Timer_TestMethod(timer
));
153 DisposeObject(timer
);
156 FreeTimerClass(timercl
);