// gcc test.c -lX11 -o test #include #include #define TIMEDIFF(t1, t2) ((t1.tv_sec-t2.tv_sec)*1000 + (t1.tv_usec-t2.tv_usec)/1000) int main() { Display *dpy; Window win; GC gc; int width = 1000; int height = 800; int black, white, x, y, i, time, len; struct timeval t1, t2; char string[300]; char buf[256]; dpy = XOpenDisplay(NULL); black = BlackPixel(dpy, DefaultScreen(dpy)); white = WhitePixel(dpy, DefaultScreen(dpy)); win = XCreateSimpleWindow(dpy, DefaultRootWindow(dpy), 0, 0, width, height, 0, white, black); XMapWindow(dpy, win); gc = XCreateGC(dpy, win, 0, NULL); for (i = 0; i < 95; i++) { string[i] = i + 32; string[i+95] = i + 32; string[i+95*2] = i + 32; } while (1) { gettimeofday(&t1, NULL); for (i = 0; i < 5; i++) { XSetForeground(dpy, gc, white); XFillRectangle(dpy, win, gc, 0, 0, width, height); XSetForeground(dpy, gc, black); XSetBackground(dpy, gc, white); len = sprintf(buf, "%i ms", time); XDrawImageString(dpy, win, gc, 5, 15, buf, len); for(y = 0; y < height/15; y ++) for(x = 0; x < width/30; x ++) XDrawImageString(dpy, win, gc, 5 + x*30 , 30 + y*15, "Test", 4); XFlush(dpy); } gettimeofday(&t2, NULL); time = TIMEDIFF(t2, t1); // printf("%i ms\n", time); } return 0; }