2 Copyright © 2003, The AROS Development Team. All rights reserved.
5 Originally written by by Rune Elvemo.
6 Improved and adapted to gcc by Fabio Alemagna.
13 #include <exec/types.h>
15 #include <devices/timer.h>
16 #include <graphics/gfxbase.h>
17 #include <graphics/gfxmacros.h>
18 #include <graphics/rastport.h>
19 #include <intuition/intuition.h>
21 #include <proto/exec.h>
22 #include <proto/timer.h>
23 #include <proto/intuition.h>
24 #include <proto/graphics.h>
25 #include <proto/dos.h>
26 #include <proto/alib.h>
28 struct Device
*TimerBase
;
29 struct MsgPort
*TimerMP
;
30 struct timerequest
*TimerIO
;
32 struct Window
*benchwin
;
33 struct Screen
*wb_screen
;
40 #define NUMITERATIONS (16*1024)
41 xypoint xytable
[NUMITERATIONS
];
46 #define DOTEST(function) \
49 struct timeval start, end; \
53 for (pen = 0; pen < NUMITERATIONS; pen++) \
55 const ULONG x = xytable[i].x; \
56 const ULONG y = xytable[i].y; \
57 struct RastPort *rport = benchwin->RPort; \
59 SetAPen(benchwin->RPort, pen); \
66 SubTime(&end,&start); \
68 printf("\nResults for " #function ":\n"); \
70 total = end.tv_secs + ((float)end.tv_micro / 1000000); \
72 printf("total time: %f\n", total); \
73 printf("iterations/sec: %f\n", pen/total); \
75 SetAPen(benchwin->RPort, 0); \
76 RectFill(benchwin->RPort, 0,0, benchwin->GZZWidth, benchwin->GZZHeight); \
79 int main(int argc
, char **argv
)
83 DOTEST(DrawCircle(rport
, x
, y
, 10));
84 DOTEST(DrawEllipse(rport
, x
, y
, 10, 20));
85 DOTEST({Move(rport
, x
, y
); Text(rport
, "BenchMark", 9);});
86 DOTEST(WritePixel(rport
, x
, y
));
87 DOTEST(RectFill(rport
, x
, y
, x
+50, y
+50));
90 WORD pnts
[] = {x
, y
, x
+10, y
+10, x
+50, y
+50}; PolyDraw(rport
, 3,pnts
);
99 wb_screen
= LockPubScreen(NULL
);
100 if (!wb_screen
) return 0;
102 benchwin
= OpenWindowTags
105 WA_Left
, 10, WA_Top
, 20,
106 WA_Width
, 640, WA_Height
, 480,
108 WA_SmartRefresh
, TRUE
,
109 WA_NoCareRefresh
, TRUE
,
110 WA_GimmeZeroZero
, TRUE
,
111 WA_Title
, (IPTR
)"Gfxlib benchmark",
112 WA_PubScreen
, (IPTR
)wb_screen
,
116 UnlockPubScreen(NULL
, wb_screen
);
118 if (!benchwin
) return 0;
120 TimerMP
= CreatePort(NULL
, 0);
121 if (!TimerMP
) return 0;
123 TimerIO
= (struct timerequest
*)CreateExtIO(TimerMP
, sizeof(struct timerequest
));
124 if (!TimerIO
) return 0;
126 if (OpenDevice(TIMERNAME
, UNIT_VBLANK
, (struct IORequest
*)TimerIO
, 0))
129 TimerBase
= TimerIO
->tr_node
.io_Device
;
132 struct timeval start
;
136 srand48(start
.tv_secs
);
138 for (i
= 0; i
< sizeof(xytable
)/sizeof(xytable
[0]); i
++)
140 xytable
[i
].x
= drand48() * benchwin
->GZZWidth
;
141 xytable
[i
].y
= drand48() * benchwin
->GZZHeight
;
150 if (TimerBase
) CloseDevice((struct IORequest
*)TimerIO
);
151 if (TimerIO
) DeleteExtIO((struct IORequest
*)TimerIO
);
152 if (TimerMP
) DeletePort(TimerMP
);
153 if (benchwin
) CloseWindow(benchwin
);