2 Copyright © 1995-2014, The AROS Development Team. All rights reserved.
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>
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
)) {
26 struct MsgPort
*port
= (struct MsgPort
*) FindTask(NULL
)->tc_UserData
;
28 for (i
= 0; i
< NUM_MESSAGES
; i
++) {
30 ReplyMsg(GetMsg(port
));
36 AROS_INTH1(intentry
, struct MsgPort
*, port
)
41 ReplyMsg(GetMsg(port
));
48 AROS_UFH2(void, callentry
,
49 AROS_UFHA(struct MsgPort
*, port
, D0
),
50 AROS_UFHA(struct ExecBase
*, SysBase
, A6
)) {
54 ReplyMsg(GetMsg(port
));
59 int main(int argc
, char **argv
) {
60 struct MsgPort
*port
, *reply
;
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
,
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
++) {
92 gettimeofday(&end
, NULL
);
94 while (end
.tv_usec
< start
.tv_usec
) {
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
++) {
116 gettimeofday(&end
, NULL
);
118 while (end
.tv_usec
< start
.tv_usec
) {
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
++) {
136 gettimeofday(&end
, NULL
);
138 while (end
.tv_usec
< start
.tv_usec
) {
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);
149 DeleteMsgPort(reply
);