linux tinydrm vs fbtft 效能對比測試
本文將透過若干組對照試驗,然後根據實驗得出的資料,計算在使用fbdev的情況下,tinydrm
相較於fbtft
的提升幅度。
免責宣告:本人時間、精力有限,實驗中的測試資料量較小,所以不建議將本文中的資料用於比較嚴謹的場景。
測試環境
開發板 | 樹莓派1代B型號 Raspberrypi Model B |
CPU | BCM2835 armv6l ARM1176@1GHz 已超頻,詳細引數見下方config.txt |
螢幕 | 128x160 st7735r 4-wire spi@12MHz |
cpuinfo
Architecture: armv6l
Byte Order: Little Endian
CPU(s): 1
On-line CPU(s) list: 0
Vendor ID: ARM
Model name: ARM1176
Model: 7
Thread(s) per core: 1
Core(s) per socket: 1
Socket(s): 1
Stepping: r0p7
CPU(s) scaling MHz: 70%
CPU max MHz: 1000.0000
CPU min MHz: 700.0000
BogoMIPS: 697.95
Flags: half thumb fastmult vfp edsp java tls
測試用例
Linux Framebuffer Benchmark : https://github.com/caramelli/fbmark
編譯選項 : -g -O2
-
fb_rectangle
-
fb_sierpinski
工具鏈資訊
❯ /opt/cross-pi-gcc/bin/arm-linux-gnueabihf-gcc -v
Using built-in specs.
COLLECT_GCC=/opt/cross-pi-gcc/bin/arm-linux-gnueabihf-gcc
COLLECT_LTO_WRAPPER=/opt/cross-pi-gcc/libexec/gcc/arm-linux-gnueabihf/12.2.0/lto-wrapper
Target: arm-linux-gnueabihf
Configured with: ../gcc-12.2.0/configure --prefix=/opt/cross-pi-gcc --target=arm-linux-gnueabihf --enable-languages=c,c++,fortran --with-arch=armv6 --with-fpu=vfp --with-float=hard --disable-multilib --includedir=/usr/arm-linux-gnueabihf/include
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 12.2.0 (GCC)
自建工具鏈方法參考:https://solarianprogrammer.com/2018/05/06/building-gcc-cross-compiler-raspberry-pi/ (此文中的編譯選項不針對於樹莓派1b。我修改了一些編譯選項以及其他引數,方才可以使用,目前正在整理中,尚未釋出。)
一般情況下,您不需要自建交叉編譯工具鏈,使用apt或buildroot提供的工具鏈進行編譯即可。
config.txt
# Please note that this is only a sample, we recommend you to change it to fit
# your needs.
# You should override this file using BR2_PACKAGE_RPI_FIRMWARE_CONFIG_FILE.
# See http://buildroot.org/manual.html#rootfs-custom
# and http://elinux.org/RPiconfig for a description of config.txt syntax
start_file=start.elf
fixup_file=fixup.dat
kernel=zImage
# To use an external initramfs file
#initramfs rootfs.cpio.gz
# Disable overscan assuming the display supports displaying the full resolution
# If the text shown on the screen disappears off the edge, comment this out
disable_overscan=1
# How much memory in MB to assign to the GPU on Pi models having
# 256, 512 or 1024 MB total memory
gpu_mem_256=100
gpu_mem_512=100
gpu_mem_1024=100
enable_uart=1
dtoverlay=i2c1-overlay
arm_freq=1000
core_freq=500
sdram_freq=600
over_voltage=6
成績對比
測試條件一 | cpu排程 powersave
設定cpu排程為省電模式(鎖最低頻率 7000MHz)
echo powersave > /sys/devices/system/cpu/cpufreq/policy0/scaling_governor
echo 0 > /sys/class/graphics/fbcon/cursor_blink # 關閉控制檯游標閃爍
測試結果
fbtft | tinydrm | 提升幅度 | 單位 | |
---|---|---|---|---|
Rectangle 32x40 | 8.55 | 17.54 | 51.26% | MPixels/second |
Sierpinski 1024 | 529.41 | 1138.67 | 53.51% | Frames/second |
Sierpinski 2048 | 295.23 | 605.58 | 51.25% | Frames/second |
Sierpinski 4096 | 156.19 | 314.06 | 50.27% | Frames/second |
Sierpinski 8192 | 80.00 | 160.37 | 50.12% | Frames/second |
Sierpinski 16384 | 42.86 | 80.83 | 46.98% | Frames/second |
Sierpinski 32768 | 23.81 | 41.01 | 41.95% | Frames/second |
Sierpinski 65536 | 14.28 | 20.76 | 31.21% | Frames/second |
Sierpinski 131072 | 9.53 | 10.42 | 8.54% | Frames/second |
Sierpinski 262144 | 5.30 | 5.30 | 0.00% | Frames/second |
結論:在多個測試專案中,tinydrm 對比 fbtft 具有100%的效能提升。
在後面的測試專案中,隨著計算複雜度的提升,tinydrm的領先幅度大幅下降,推測瓶頸可能來到cpu這邊,暫未進行驗證,需要更多資料支援該推測。
測試條件二 | cpu排程 performance
設定cpu排程為效能模式(鎖最高頻率 1GHz)
echo performance > /sys/devices/system/cpu/cpufreq/policy0/scaling_governor
echo 0 > /sys/class/graphics/fbcon/cursor_blink # 關閉控制檯游標閃爍
測試結果
fbtft | tinydrm | 提升幅度 | 單位 | |
---|---|---|---|---|
Rectangle 32x40 | 17.12 | 25.84 | 33.74% | MPixels/second |
Sierpinski 1024 | 1155.75 | 1701.89 | 32.09% | Frames/second |
Sierpinski 2048 | 586.88 | 900.29 | 34.81% | Frames/second |
Sierpinski 4096 | 319.47 | 464.54 | 31.22% | Frames/second |
Sierpinski 8192 | 159.61 | 236.52 | 32.51% | Frames/second |
Sierpinski 16384 | 88.58 | 118.88 | 25.48% | Frames/second |
Sierpinski 32768 | 49.63 | 59.97 | 22.24% | Frames/second |
Sierpinski 65536 | 25.15 | 30.08 | 16.38% | Frames/second |
Sierpinski 131072 | 12.50 | 15.08 | 17.10% | Frames/second |
Sierpinski 262144 | 7.65 | 7.65 | 0.00% | Frames/second |
結論:在提升cpu頻率後,tinydrm的領先幅度相較於之前有所下降,fbtft的測試成績有明顯提升,這可能是fbtft框架過於依賴cpu能力導致的。
調整spi頻率後的成績對比
暫未完成