测试内容:
1)全屏搬运图片 次数10000
2) 同时运行1、2、3、4个程序
3)计算平均时间(取5次平均值)
4)计算CPU占用率
========================
测试代码:
硬件加速:S3C6410 Linux 2D Accelerate Test Program v1.0
软件搬运:见附录
所有代码使用 -O2优化
========================
测试结果:
搬运时间
CPU占用率
============================
结论:使用2D加速无论是在搬运速度还是在CPU占用率上都有很大优势,特别在多个进程并发的情况下,可以大幅节省时间。
=====================================================
附录 软件搬运测试代码
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <sys/types.h>
#include <sys/mman.h>
#include "s3c_g2d.h"
#include "fb.h"
//#define S3C_G2D_DEV_NAME "/dev/s3c-g2d"
#define S3C_FB_DEV_NAME "/dev/fb0"
int g2d_fd;
int fb_fd;
FILE *file_fd;
int file_len;
static unsigned char *file_name;
unsigned int *pic_buffer;
int width = 480;
int height = 272;
int main(int argc, char *argv[])
{
printf("This is a S3C6410 2d test program/n");
///
//file operaton
//
file_name = argv[1];
file_fd = fopen(file_name, "r");
fseek(file_fd,0,SEEK_END); //定位到文件末
file_len = ftell(file_fd); //文件长度
fclose(file_fd);
file_fd = fopen(file_name, "r");
pic_buffer = malloc(file_len);
fread(pic_buffer, file_len, 1, file_fd);
//memcpy(buffer,pic_buffer,file_len);
/
g2d_fd = open(S3C_G2D_DEV_NAME, O_RDWR);//open g2d
if( g2d_fd < 0 )
printf("open g2d device error!/n ");
fb_fd = open(S3C_FB_DEV_NAME, O_RDWR, 0);//open fb0
if( fb_fd < 0 )
printf("open framebuffer device error!/n ");
struct fb_fix_screeninfo finfo;
if (ioctl(fb_fd, FBIOGET_FSCREENINFO, &finfo) == -1)
printf("get fix info error!/n");
struct fb_var_screeninfo info;
if (ioctl(fb_fd, FBIOGET_VSCREENINFO, &info) == -1)
printf("get var info error!/n");
printf( "using (fd=%d)/n"
"id = %s/n"
"xres = %d px/n"
"yres = %d px/n"
"xres_virtual = %d px/n"
"yres_virtual = %d px/n"
"bpp = %d/n"
"r = %2u:%u/n"
"g = %2u:%u/n"
"b = %2u:%u/n",
fb_fd,
finfo.id,
info.xres,
info.yres,
info.xres_virtual,
info.yres_virtual,
info.bits_per_pixel,
info.red.offset, info.red.length,
info.green.offset, info.green.length,
info.blue.offset, info.blue.length
);
//mmap
void* lcd_buffer = (unsigned short*) mmap(
0, finfo.smem_len,
PROT_READ | PROT_WRITE,
MAP_SHARED,
fb_fd, 0);
if (lcd_buffer == MAP_FAILED)
printf("mmap fb error!/n");
int count ;
for(count = 0; count < 10000 ; count++)
{
memcpy(lcd_buffer,pic_buffer,finfo.smem_len);
}
end:
close(g2d_fd);
close(fb_fd);
fclose(file_fd);
return 0;
}