www.pudn.com > microwin-0.89.rar > speed.c
#include#include #include #ifdef TEST_FOR_X #include #else #define MWINCLUDECOLORS #include #endif #define NUM_POINTS 80 time_t start_time, end_time; void start_timer() { time(&start_time); } void end_timer() { time(&end_time); printf("start=%lu, end=%lu, time=%lu\n", start_time, end_time, end_time-start_time); } int main() { #ifdef TEST_FOR_X Display *display; Window window; GC gc; XGCValues gcValues; Colormap colormap; Pixmap src_pixmap; unsigned long fgColor, bgColor; int screenNum; XPoint points[NUM_POINTS]; #else GR_WINDOW_ID window; GR_WINDOW_ID src_pixmap; unsigned char* src_pixmap_buf[320*240*2]; GR_GC_ID gc; GR_POINT points[NUM_POINTS]; #endif int c, c1, count=4500; int x, y, x1, y1, x2, y2; #ifdef TEST_FOR_X if(!(display=XOpenDisplay(""))) { printf("Cannot connect to X.\n"); } screenNum = DefaultScreen(display); colormap = DefaultColormap(display, screenNum); bgColor = BlackPixel(display, screenNum); fgColor = WhitePixel(display, screenNum); window = XCreateSimpleWindow(display, RootWindow(display, screenNum), 0, 0 , 639, 479, 0, fgColor, bgColor); src_pixmap = XCreatePixmap(display, window, 320, 240, 16); XMapRaised(display, window); gcValues.background = bgColor; gcValues.foreground = fgColor; gcValues.line_width = 1; gcValues.line_style = LineSolid; gcValues.fill_style = FillSolid; gcValues.fill_rule = WindingRule; gcValues.arc_mode = ArcPieSlice; gc = XCreateGC(display, window, GCForeground | GCBackground | GCLineWidth | GCLineStyle | GCFillStyle, &gcValues); #else GrOpen(); window = GrNewWindow(GR_ROOT_WINDOW_ID, 0, 0, 639, 479, 0, BLACK, BLUE); src_pixmap = GrNewPixmap(640, 480, src_pixmap_buf); GrMapWindow(window); gc = GrNewGC(); GrSetGCForeground(gc, WHITE); GrSetGCBackground(gc, BLACK); GrSetGCMode(gc, GR_MODE_COPY); #endif // Horizontal Line //////////////////////////////////////////////// printf("Horizontal Line(XDrawLine)\n"); start_timer(); for(c=0; c