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_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
)) {
60 AROS_UFH2(void, callentry
,
61 AROS_UFHA(struct MsgPort
*, port
, D0
),
62 AROS_UFHA(struct ExecBase
*, SysBase
, A6
)) {
66 ReplyMsg(GetMsg(port
));
71 int main(int argc
, char **argv
) {
72 struct MsgPort
*port
, *reply
;
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
,
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
++) {
104 gettimeofday(&end
, NULL
);
106 while (end
.tv_usec
< start
.tv_usec
) {
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
++) {
128 gettimeofday(&end
, NULL
);
130 while (end
.tv_usec
< start
.tv_usec
) {
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
++) {
148 gettimeofday(&end
, NULL
);
150 while (end
.tv_usec
< start
.tv_usec
) {
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
++) {
170 gettimeofday(&end
, NULL
);
172 while (end
.tv_usec
< start
.tv_usec
) {
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);
183 DeleteMsgPort(reply
);