性能测试
为了为日后优化提供数据参考,我今天测试了一下LCD的性能,给大家做一下参考.采用测试套件 /skyeye-testsuite-1.2.5/linux/s3c2410/s3c2410x-2.6.14
Target:s3c2410 with LCD and without net
Host:Ubuntu 2.6.22.18 GTK mod
在我的机器上的测试数据是:
Enter 'help' for a list of built-in commands.
/bin/ash: can't access tty; job control turned off
/ $cnt:20 cost:280007us average:14000us fps:4
cnt:20 cost:260004us average:13000us fps:4
cnt:20 cost:310002us average:15500us fps:4
cnt:20 cost:270010us average:13500us fps:4
cnt:20 cost:270003us average:13500us fps:4
cnt:20 cost:220000us average:11000us fps:4
cnt:20 cost:260010us average:13000us fps:4
cnt:20 cost:260002us average:13000us fps:4
cnt:20 cost:240000us average:12000us fps:4
cnt:20 cost:260010us average:13000us fps:4
可以看到fps大约只有4,也就是说每秒更新4帧
这是符合设计的,因为在函数gtk_lcd_open中
有lcd->timer = gtk_timeout_add(200, (GtkFunction)callback_redraw, lcd->window);
就是200ms更新一次.如果要加速LCD的速度,这个参数是可考虑因素.
尝试修改,得到下面数据
更新间隔ms fps 每次更新耗时
200 4 12ms
100 9 11ms
50 19 13ms (skyeye 响应速度很慢,console基本不可操作)
根据经验,想要流畅地操作GUI, LCD fps至少要到30.
从实验的结果可以知道,简单地修改定时更新,是不可能达到目的.
另外就是上面帖子中提到的divisor,现在的代码里面是50,也就是50分频.
由于Skyeye模拟ARM的真实频率很低,50分频后的速度就更慢了
divisor fps 每次更新耗时
50 4 12ms
25 4 13ms
10 4 13ms
可以看到fps没有改变,这是因为GTK后端的update函数并不控制画图
static int gtk_lcd_update(struct lcd_device *lcd_dev)
{
if (lcd_dev == NULL || lcd_dev->priv == NULL) return -1;
gtk_main_iteration_do(FALSE);
return 0;
}
只检查GTK是否有事件要处理.所以在GTK后端下,改变divisor只会加速鼠标的响应速度,并不会加速绘图.
这个跟帖子里面讨论的加速是矛盾的.(当然对win32后端是有效的,因为win32后端的update是控制绘图的)
=========测试代码如下===================
static gint callback_expose_event(GtkWidget *widget, GdkEventExpose *event, SkyEyeLCD_GTK *lcd)
{
int i, j, x, y, pix, bit;
int wordnum; //for lcd_depth==16 , 1 word contain 2 pixel
guint32 fbdata; // |R1,G1,B1,R0,G0,B0|
int tribytenum; //for lcd_depth==12, 3 byte contain 2 pixel
guchar fbdata8_0; // |G0,R0|
guchar fbdata8_1; // |R1,B0|
guchar fbdata8_2; // |B1,G1|
struct timeval tv,tv1;
static struct timeval tvold;
long cost=0,cost1=0;
static long sum=0, sum1=0;
static long cnt=0;
GdkRectangle rect;
if (lcd == NULL || lcd->dev == NULL) return FALSE;
gettimeofday(&tv, NULL);
cost1 = (tv.tv_sec - tvold.tv_sec)* 1000000 + tv.tv_usec-tvold.tv_usec;
if (cost1 !=0 ) sum1 += cost1;
tvold.tv_sec = tv.tv_sec;
tvold.tv_usec = tv.tv_usec;//从这里开始是原始代码
if (lcd->update_all == FALSE) {
if (lcd->update_rect.width < 0 || lcd->update_rect.height < 0) return TRUE;
rect = lcd->update_rect;
rect.width += 1;
rect.height += 1;
lcd->update_rect.x = 0;
...............................
case 32:
gdk_draw_rgb_32_image(widget->window,
widget->style->fg_gc,
0, rect.y, lcd->width, rect.height,
GDK_RGB_DITHER_NORMAL,
(guchar*)((u32*)lcd->rgbbuf + rect.y * lcd->virtual_width),
lcd->virtual_width * 4);
break;
default:
break;
}
//新增加的统计部分
gettimeofday(&tv1, NULL);
cost = (tv1.tv_sec - tv.tv_sec)* 1000000 + tv1.tv_usec-tv.tv_usec;
//printf("\n usec:%ld", cost );
sum += cost;
cnt ++;
if(cnt >= 20)
{
printf("\n cnt:%d cost:%dus average:%ldus ", cnt, sum, sum/cnt);
printf("fps:%ld", cnt*1000000/sum1 );
cnt = 0;
sum = sum1 = 0;
cost = cost1 = 0;
}
return TRUE;
}
再通报一下
LCD仿真速度已经可以达到30fps(30~50fps)之间是在remote X server的方式测试得到的数据,本地测试应该会稍微更快一点.
(因为目前LCD更新频率的限制, fps会达到一个极限值,大约在50左右吧)
公司里没法上传代码.
晚上回家再开一个新帖 测试贴图
页:
1
[2]