00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #include "FBlib.h"
00017 #include <stdio.h>
00018 #include <stdlib.h>
00019 #include <time.h>
00020
00021 #define MAX_SECS 30
00022 #define UPDATE_INTERVAL 5
00023
00024 int update;
00025
00026 void sig_alarm(int sig)
00027 {
00028 update=1;
00029
00030 }
00031
00032 int main()
00033 {
00034 FB_pixel col;
00035 int x, xfont, y, yfont;
00036 long start_time, cur_time;
00037 long num_pixels = 0;
00038
00039 FB_initlib("/dev/fb0");
00040 signal(SIGALRM, sig_alarm);
00041 srandom(time(NULL));
00042 FB_getres(&x, &y);
00043 y -= 20;
00044 yfont = y+2;
00045 xfont = 10;
00046 FB_rectfill(0, y, x, y+20, FB_makecol(0,0,0,0));
00047 alarm(UPDATE_INTERVAL);
00048 start_time = time(NULL);
00049 cur_time = time(NULL);
00050 update = 1;
00051 while((cur_time - start_time) < MAX_SECS)
00052 {
00053 if(update)
00054 {
00055 update=0;
00056 cur_time = time(NULL);
00057 signal(SIGALRM, sig_alarm);
00058 alarm(UPDATE_INTERVAL);
00059 FB_rectfill(0, y, x, y+20, FB_makecol(0,0,0,0));
00060 FB_printf(xfont, yfont, FB_makecol(255,255,255,0), "This test takes 30 seconds, drawn %g pixels/s", (double)num_pixels/(cur_time - start_time));
00061 }
00062 col=FB_makecol(random()%255,random()%255,random()%255,random()%255);
00063 FB_putpixel(random()%x,random()%y,col);
00064 num_pixels++;
00065 }
00066 FB_clear_screen(FB_makecol(0,0,0,0));
00067 FB_exit();
00068 printf("Drawn %g pixels in %d seconds, it's %g pixels/s\n", (double)num_pixels, MAX_SECS, (double)num_pixels/MAX_SECS);
00069 return 0;
00070 }