use the locations specified in the bcm2708_boot header
[AROS.git] / test / OOPDemos / test.c
blob7f92efaefe4d800b92e0df9991a72555dbd60800
1 /*
2 Copyright © 1997-98, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Demo of new OOP system
6 Lang: english
7 */
9 #include "oop.h"
10 #include "timerclass.h"
11 #include "protos.h"
12 #include "support.h"
13 #include "hash.h"
14 #include <stdio.h>
16 #define SDEBUG 1
17 #define DEBUG 1
18 #include "debug.h"
20 extern struct OOPBase *oopbase;
21 SDInit;
24 #define NUM_ITERATIONS (10000000)
26 IPTR TestFunc(Class *cl, Object *o, Msg msg)
28 return (12345678);
32 int main(int argc, char **argv)
35 if (InitOOP())
37 Class *timercl;
39 printf("Object system initialized\n");
42 /* Initialize the timer class */
43 timercl = MakeTimerClass();
44 if (timercl)
47 struct Node *n;
48 Object *timer;
50 printf("Class list:\n");
51 ForeachNode(&(oopbase->ClassList), n)
53 printf("%s\n", n->ln_Name);
55 printf("\n\n");
57 #if (HASHED_IFS || HASHED_METHODS)
58 { ULONG i;
59 printf("Hash table:\n");
60 for (i = 0; i < HashSize(timercl->HashTable); i ++)
62 struct Bucket *b;
63 printf ("%ld:", i);
64 for (b = (struct Bucket *)timercl->HashTable[i]; b; b = b->Next)
65 printf (" %ld %p", b->ID, b);
67 printf("\n");
70 #endif
72 #if (HASHED_STRINGS)
73 { ULONG i;
74 printf("Hash table:\n");
75 for (i = 0; i < HashSize(timercl->HashTable); i ++)
77 struct Bucket *b;
78 printf ("%ld:", i);
79 for (b = (struct Bucket *)timercl->HashTable[i]; b; b = b->Next)
80 printf (" %s %p", (STRPTR)b->ID, b);
82 printf("\n");
85 #endif
88 /* Create a new instance */
89 timer = NewObject(NULL, TIMERCLASS, NULL);
90 if (timer)
92 ULONG i;
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");
103 Timer_Start(timer);
105 for (i = 0; i < NUM_ITERATIONS; i ++)
107 Timer_TestMethod(timer);
110 Timer_Stop(timer);
111 printf("Time elapsed: ");
112 Timer_PrintElapsed(timer);
115 /* Function test */
116 printf("\nTen billion calls to empty *function*\n");
117 Timer_Start(timer);
119 for (i = 0; i < NUM_ITERATIONS; i ++)
121 TestFunc(timercl, timer, (Msg)&methodid);
125 Timer_Stop(timer);
126 printf("Time elapsed: ");
127 Timer_PrintElapsed(timer);
131 /* Loop test */
132 printf("\nLooping ten billion times\n");
133 Timer_Start(timer);
135 for (i = 0; i < NUM_ITERATIONS; i ++)
137 ULONG retval;
138 retval = 12345678;
141 Timer_Stop(timer);
142 printf("Time elapsed: ");
143 Timer_PrintElapsed(timer);
145 printf("\n\nTestMethod output: %ld\n", Timer_TestMethod(timer));
147 /* Dispose object */
148 DisposeObject(timer);
151 FreeTimerClass(timercl);
153 CleanupOOP();
156 return (0);