Removed code that used to test a feature only supported in
[AROS.git] / test / timeport.c
blobdb01f0dbd0067ef1e78a320e0c977b41fdc56c22
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_UFH2(void, callentry,
49 AROS_UFHA(struct MsgPort *, port, D0),
50 AROS_UFHA(struct ExecBase *, SysBase, A6)) {
51 AROS_USERFUNC_INIT
53 WaitPort(port);
54 ReplyMsg(GetMsg(port));
56 AROS_USERFUNC_EXIT
59 int main(int argc, char **argv) {
60 struct MsgPort *port, *reply;
61 struct Message *msg;
62 struct Process *proc;
63 int i;
64 struct timeval start, end;
65 struct Interrupt *intr;
67 printf("testing with %d messages\n", NUM_MESSAGES);
69 port = CreateMsgPort();
70 reply = CreateMsgPort();
72 msg = AllocVec(sizeof(struct Message), MEMF_PUBLIC | MEMF_CLEAR);
73 msg->mn_Length = sizeof(struct Message);
74 msg->mn_ReplyPort = reply;
76 proc = CreateNewProcTags(NP_Entry, (IPTR) taskentry,
77 NP_Name, "timeport task",
78 NP_UserData, (IPTR) port,
79 TAG_DONE);
81 port->mp_Flags = PA_SIGNAL;
82 port->mp_SigTask = (struct Task *) proc;
84 gettimeofday(&start, NULL);
86 for (i = 0; i < NUM_MESSAGES; i++) {
87 PutMsg(port, msg);
88 WaitPort(reply);
89 GetMsg(reply);
92 gettimeofday(&end, NULL);
94 while (end.tv_usec < start.tv_usec) {
95 end.tv_sec--;
96 end.tv_usec += 1000000;
99 printf("PA_SIGNAL: %ld.%lds\n",(long)( end.tv_sec - start.tv_sec), (long)(end.tv_usec - start.tv_usec) / 1000);
101 intr = AllocVec(sizeof(struct Interrupt), MEMF_PUBLIC | MEMF_CLEAR);
102 intr->is_Code = (APTR)intentry;
103 intr->is_Data = port;
105 port->mp_Flags = PA_SOFTINT;
106 port->mp_SoftInt = intr;
108 gettimeofday(&start, NULL);
110 for (i = 0; i < NUM_MESSAGES; i++) {
111 PutMsg(port, msg);
112 WaitPort(reply);
113 GetMsg(reply);
116 gettimeofday(&end, NULL);
118 while (end.tv_usec < start.tv_usec) {
119 end.tv_sec--;
120 end.tv_usec += 1000000;
123 printf("PA_SOFTINT: %ld.%lds\n", (long)(end.tv_sec - start.tv_sec), (long)(end.tv_usec - start.tv_usec) / 1000);
125 port->mp_Flags = PA_CALL;
126 port->mp_SigTask = callentry;
128 gettimeofday(&start, NULL);
130 for (i = 0; i < NUM_MESSAGES; i++) {
131 PutMsg(port, msg);
132 WaitPort(reply);
133 GetMsg(reply);
136 gettimeofday(&end, NULL);
138 while (end.tv_usec < start.tv_usec) {
139 end.tv_sec--;
140 end.tv_usec += 1000000;
143 printf("PA_CALL: %ld.%lds\n", (long)(end.tv_sec - start.tv_sec), (long)(end.tv_usec - start.tv_usec) / 1000);
145 FreeVec(intr);
147 FreeVec(msg);
149 DeleteMsgPort(reply);
150 DeleteMsgPort(port);
152 return 0;