Main Page   File List   Globals  

tests/test1.c

00001 /***************************************************************************
00002                        test1.c  -  test putpixel speed
00003                              -------------------
00004     begin                : Wed Dec 27 2000
00005     copyright            : (C) 2000 by Daniele Venzano
00006     email                : webvenza@libero.it
00007  ***************************************************************************/
00008 
00009 /***************************************************************************
00010  *                                                                         *
00011  *   This program is free software; you can redistribute it and/or modify  *
00012  *   it under the terms of the GNU General Public License as published by  *
00013  *   the Free Software Foundation; version 2 of the License.               *
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 }

Generated on Sat Jul 5 09:04:51 2003 for LibFB by doxygen1.2.18