Find a matching filesystem in FileSystem.resource by handler name rather
[AROS.git] / test / timeport.c
blob0fa55fcb0edf8185ec48cfdacfc7a8176411749b
1 /*
2 Copyright © 1995-2014, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #include <exec/types.h>
7 #include <exec/ports.h>
8 #include <dos/dosextens.h>
9 #include <dos/dostags.h>
10 #include <aros/libcall.h>
11 #include <proto/exec.h>
12 #include <proto/dos.h>
13 #include <stdio.h>
14 #include <sys/time.h>
15 #include <time.h>
17 #define NUM_MESSAGES (1000000)
19 AROS_UFH3(void, taskentry,
20 AROS_UFHA(STRPTR, argPtr, A0),
21 AROS_UFHA(ULONG, argSize, D0),
22 AROS_UFHA(struct ExecBase *, SysBase, A6)) {
23 AROS_USERFUNC_INIT
25 int i;
26 struct MsgPort *port = (struct MsgPort *) FindTask(NULL)->tc_UserData;
28 for (i = 0; i < NUM_MESSAGES; i++) {
29 WaitPort(port);
30 ReplyMsg(GetMsg(port));
33 AROS_USERFUNC_EXIT
36 AROS_INTH1(intentry, struct MsgPort *, port)
38 AROS_INTFUNC_INIT
40 WaitPort(port);
41 ReplyMsg(GetMsg(port));
43 return 0;
45 AROS_INTFUNC_EXIT
48 AROS_UFH4(void, fastentry,
49 AROS_UFHA(APTR, data, A1),
50 AROS_UFHA(APTR, code, A5),
51 AROS_UFHA(struct Message *, msg, D0),
52 AROS_UFHA(struct ExecBase *, SysBase, A6)) {
53 AROS_USERFUNC_INIT
55 ReplyMsg(msg);
57 AROS_USERFUNC_EXIT
60 AROS_UFH2(void, callentry,
61 AROS_UFHA(struct MsgPort *, port, D0),
62 AROS_UFHA(struct ExecBase *, SysBase, A6)) {
63 AROS_USERFUNC_INIT
65 WaitPort(port);
66 ReplyMsg(GetMsg(port));
68 AROS_USERFUNC_EXIT
71 int main(int argc, char **argv) {
72 struct MsgPort *port, *reply;
73 struct Message *msg;
74 struct Process *proc;
75 int i;
76 struct timeval start, end;
77 struct Interrupt *intr;
79 printf("testing with %d messages\n", NUM_MESSAGES);
81 port = CreateMsgPort();
82 reply = CreateMsgPort();
84 msg = AllocVec(sizeof(struct Message), MEMF_PUBLIC | MEMF_CLEAR);
85 msg->mn_Length = sizeof(struct Message);
86 msg->mn_ReplyPort = reply;
88 proc = CreateNewProcTags(NP_Entry, (IPTR) taskentry,
89 NP_Name, "timeport task",
90 NP_UserData, (IPTR) port,
91 TAG_DONE);
93 port->mp_Flags = PA_SIGNAL;
94 port->mp_SigTask = (struct Task *) proc;
96 gettimeofday(&start, NULL);
98 for (i = 0; i < NUM_MESSAGES; i++) {
99 PutMsg(port, msg);
100 WaitPort(reply);
101 GetMsg(reply);
104 gettimeofday(&end, NULL);
106 while (end.tv_usec < start.tv_usec) {
107 end.tv_sec--;
108 end.tv_usec += 1000000;
111 printf("PA_SIGNAL: %ld.%lds\n",(long)( end.tv_sec - start.tv_sec), (long)(end.tv_usec - start.tv_usec) / 1000);
113 intr = AllocVec(sizeof(struct Interrupt), MEMF_PUBLIC | MEMF_CLEAR);
114 intr->is_Code = (APTR)intentry;
115 intr->is_Data = port;
117 port->mp_Flags = PA_SOFTINT;
118 port->mp_SoftInt = intr;
120 gettimeofday(&start, NULL);
122 for (i = 0; i < NUM_MESSAGES; i++) {
123 PutMsg(port, msg);
124 WaitPort(reply);
125 GetMsg(reply);
128 gettimeofday(&end, NULL);
130 while (end.tv_usec < start.tv_usec) {
131 end.tv_sec--;
132 end.tv_usec += 1000000;
135 printf("PA_SOFTINT: %ld.%lds\n", (long)(end.tv_sec - start.tv_sec), (long)(end.tv_usec - start.tv_usec) / 1000);
137 port->mp_Flags = PA_CALL;
138 port->mp_SigTask = callentry;
140 gettimeofday(&start, NULL);
142 for (i = 0; i < NUM_MESSAGES; i++) {
143 PutMsg(port, msg);
144 WaitPort(reply);
145 GetMsg(reply);
148 gettimeofday(&end, NULL);
150 while (end.tv_usec < start.tv_usec) {
151 end.tv_sec--;
152 end.tv_usec += 1000000;
155 printf("PA_CALL: %ld.%lds\n", (long)(end.tv_sec - start.tv_sec), (long)(end.tv_usec - start.tv_usec) / 1000);
157 intr->is_Code = fastentry;
159 port->mp_Flags = PA_FASTCALL;
160 port->mp_SoftInt = intr;
162 gettimeofday(&start, NULL);
164 for (i = 0; i < NUM_MESSAGES; i++) {
165 PutMsg(port, msg);
166 WaitPort(reply);
167 GetMsg(reply);
170 gettimeofday(&end, NULL);
172 while (end.tv_usec < start.tv_usec) {
173 end.tv_sec--;
174 end.tv_usec += 1000000;
177 printf("PA_FASTCALL: %ld.%lds\n", (long)(end.tv_sec - start.tv_sec), (long)(end.tv_usec - start.tv_usec) / 1000);
179 FreeVec(intr);
181 FreeVec(msg);
183 DeleteMsgPort(reply);
184 DeleteMsgPort(port);
186 return 0;