emul-handler: fh_Arg1 should be the only element of struct FileHandle touched during...
[AROS.git] / test / timeport.c
blob6d5ff0bb9ac72f2b6234af23a3cca5bb49f81192
1 #include <exec/types.h>
2 #include <exec/ports.h>
3 #include <dos/dosextens.h>
4 #include <dos/dostags.h>
5 #include <aros/libcall.h>
6 #include <proto/exec.h>
7 #include <proto/dos.h>
8 #include <stdio.h>
9 #include <sys/time.h>
10 #include <time.h>
12 #define NUM_MESSAGES (1000000)
14 AROS_UFH3(void, taskentry,
15 AROS_UFHA(STRPTR, argPtr, A0),
16 AROS_UFHA(ULONG, argSize, D0),
17 AROS_UFHA(struct ExecBase *, SysBase, A6)) {
18 AROS_USERFUNC_INIT
20 int i;
21 struct MsgPort *port = (struct MsgPort *) FindTask(NULL)->tc_UserData;
23 for (i = 0; i < NUM_MESSAGES; i++) {
24 WaitPort(port);
25 ReplyMsg(GetMsg(port));
28 AROS_USERFUNC_EXIT
31 AROS_INTH1(intentry, struct MsgPort *, port)
33 AROS_INTFUNC_INIT
35 WaitPort(port);
36 ReplyMsg(GetMsg(port));
38 return 0;
40 AROS_INTFUNC_EXIT
43 AROS_UFH4(void, fastentry,
44 AROS_UFHA(APTR, data, A1),
45 AROS_UFHA(APTR, code, A5),
46 AROS_UFHA(struct Message *, msg, D0),
47 AROS_UFHA(struct ExecBase *, SysBase, A6)) {
48 AROS_USERFUNC_INIT
50 ReplyMsg(msg);
52 AROS_USERFUNC_EXIT
55 AROS_UFH2(void, callentry,
56 AROS_UFHA(struct MsgPort *, port, D0),
57 AROS_UFHA(struct ExecBase *, SysBase, A6)) {
58 AROS_USERFUNC_INIT
60 WaitPort(port);
61 ReplyMsg(GetMsg(port));
63 AROS_USERFUNC_EXIT
66 int main(int argc, char **argv) {
67 struct MsgPort *port, *reply;
68 struct Message *msg;
69 struct Process *proc;
70 int i;
71 struct timeval start, end;
72 struct Interrupt *intr;
74 printf("testing with %d messages\n", NUM_MESSAGES);
76 port = CreateMsgPort();
77 reply = CreateMsgPort();
79 msg = AllocVec(sizeof(struct Message), MEMF_PUBLIC | MEMF_CLEAR);
80 msg->mn_Length = sizeof(struct Message);
81 msg->mn_ReplyPort = reply;
83 proc = CreateNewProcTags(NP_Entry, (IPTR) taskentry,
84 NP_Name, "timeport task",
85 NP_UserData, (IPTR) port,
86 TAG_DONE);
88 port->mp_Flags = PA_SIGNAL;
89 port->mp_SigTask = (struct Task *) proc;
91 gettimeofday(&start, NULL);
93 for (i = 0; i < NUM_MESSAGES; i++) {
94 PutMsg(port, msg);
95 WaitPort(reply);
96 GetMsg(reply);
99 gettimeofday(&end, NULL);
101 while (end.tv_usec < start.tv_usec) {
102 end.tv_sec--;
103 end.tv_usec += 1000000;
106 printf("PA_SIGNAL: %ld.%lds\n",(long)( end.tv_sec - start.tv_sec), (long)(end.tv_usec - start.tv_usec) / 1000);
108 intr = AllocVec(sizeof(struct Interrupt), MEMF_PUBLIC | MEMF_CLEAR);
109 intr->is_Code = (APTR)intentry;
110 intr->is_Data = port;
112 port->mp_Flags = PA_SOFTINT;
113 port->mp_SoftInt = intr;
115 gettimeofday(&start, NULL);
117 for (i = 0; i < NUM_MESSAGES; i++) {
118 PutMsg(port, msg);
119 WaitPort(reply);
120 GetMsg(reply);
123 gettimeofday(&end, NULL);
125 while (end.tv_usec < start.tv_usec) {
126 end.tv_sec--;
127 end.tv_usec += 1000000;
130 printf("PA_SOFTINT: %ld.%lds\n", (long)(end.tv_sec - start.tv_sec), (long)(end.tv_usec - start.tv_usec) / 1000);
132 port->mp_Flags = PA_CALL;
133 port->mp_SigTask = callentry;
135 gettimeofday(&start, NULL);
137 for (i = 0; i < NUM_MESSAGES; i++) {
138 PutMsg(port, msg);
139 WaitPort(reply);
140 GetMsg(reply);
143 gettimeofday(&end, NULL);
145 while (end.tv_usec < start.tv_usec) {
146 end.tv_sec--;
147 end.tv_usec += 1000000;
150 printf("PA_CALL: %ld.%lds\n", (long)(end.tv_sec - start.tv_sec), (long)(end.tv_usec - start.tv_usec) / 1000);
152 intr->is_Code = fastentry;
154 port->mp_Flags = PA_FASTCALL;
155 port->mp_SoftInt = intr;
157 gettimeofday(&start, NULL);
159 for (i = 0; i < NUM_MESSAGES; i++) {
160 PutMsg(port, msg);
161 WaitPort(reply);
162 GetMsg(reply);
165 gettimeofday(&end, NULL);
167 while (end.tv_usec < start.tv_usec) {
168 end.tv_sec--;
169 end.tv_usec += 1000000;
172 printf("PA_FASTCALL: %ld.%lds\n", (long)(end.tv_sec - start.tv_sec), (long)(end.tv_usec - start.tv_usec) / 1000);
174 FreeVec(intr);
176 FreeVec(msg);
178 DeleteMsgPort(reply);
179 DeleteMsgPort(port);
181 return 0;