Skip to content

Commit

Permalink
ci(runner): Add benchmark example and print benchmark results.
Browse files Browse the repository at this point in the history
  • Loading branch information
espzav committed Jan 17, 2025
1 parent ca23afe commit 96f0307
Show file tree
Hide file tree
Showing 19 changed files with 663 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/build-run-applications.yml
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,9 @@ jobs:
with:
name: ${{ env.TEST_RESULT_NAME }}
path: ${{ env.TEST_RESULT_FILE }}
with:
pattern: benchmark_*.md
path: benchmark

publish-results:
name: Publish Test results
Expand All @@ -182,6 +185,9 @@ jobs:
with:
pattern: test_results_*
path: test_results
with:
pattern: benchmark_*.md
path: benchmark
- name: Publish Test Results
uses: EnricoMi/publish-unit-test-result-action@v2
with:
Expand Down
10 changes: 10 additions & 0 deletions examples/display_lvgl_benchmark/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# For more information about build system see
# https://docs.espressif.com/projects/esp-idf/en/latest/api-guides/build-system.html
# The following five lines of boilerplate have to be in your project's
# CMakeLists in this exact order for cmake to work correctly
cmake_minimum_required(VERSION 3.5)

set(COMPONENTS main) # "Trim" the build. Include the minimal set of components; main and anything it depends on.
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
add_compile_options("-Wno-attributes") # For LVGL code
project(display_lvgl_benchmark)
17 changes: 17 additions & 0 deletions examples/display_lvgl_benchmark/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Display LVGL Benchmark

This example shows LVGL internal benchmark demo.

## How to use the example

### Hardware Required

* ESP32-S3-LCD-EV-Board or ESP32-S3-LCD-EV-Board-2
* USB-C Cable

### Compile and flash

```
idf.py -p COMx build flash monitor
```

17 changes: 17 additions & 0 deletions examples/display_lvgl_benchmark/main/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
set(LV_DEMO_DIR "")
set(LV_DEMOS_SOURCES "")
if(CONFIG_LV_USE_DEMO_BENCHMARK)
list(APPEND LV_DEMO_DIR ../managed_components/lvgl__lvgl/demos)
file(GLOB_RECURSE LV_DEMOS_SOURCES ${LV_DEMO_DIR}/*.c)
endif()

idf_component_register(
SRCS "main.c" ${LV_DEMOS_SOURCES}
INCLUDE_DIRS "." ${LV_DEMO_DIR})

if(CONFIG_LV_USE_DEMO_BENCHMARK)
set_source_files_properties(
${LV_DEMOS_SOURCES}
PROPERTIES COMPILE_OPTIONS
-DLV_LVGL_H_INCLUDE_SIMPLE)
endif()
5 changes: 5 additions & 0 deletions examples/display_lvgl_benchmark/main/idf_component.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
description: BSP Display rotation example
dependencies:
esp32_p4_function_ev_board:
version: '*'
override_path: ../../../bsp/esp32_p4_function_ev_board
39 changes: 39 additions & 0 deletions examples/display_lvgl_benchmark/main/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: CC0-1.0
*/

#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "esp_log.h"

#include "lv_demos.h"
#include "bsp/esp-bsp.h"

static char *TAG = "app_main";

#define LOG_MEM_INFO (0)

void app_main(void)
{
/* Initialize display and LVGL */
bsp_display_start();

#if CONFIG_BSP_DISPLAY_LVGL_AVOID_TEAR
ESP_LOGI(TAG, "Avoid lcd tearing effect");
#if CONFIG_BSP_DISPLAY_LVGL_FULL_REFRESH
ESP_LOGI(TAG, "LVGL full-refresh");
#elif CONFIG_BSP_DISPLAY_LVGL_DIRECT_MODE
ESP_LOGI(TAG, "LVGL direct-mode");
#endif
#endif

/* Set display brightness to 100% */
bsp_display_backlight_on();

ESP_LOGI(TAG, "Display LVGL demo");
bsp_display_lock(0);
lv_demo_benchmark(); /* A demo to measure the performance of LVGL or to compare different settings. */
bsp_display_unlock();
}
5 changes: 5 additions & 0 deletions examples/display_lvgl_benchmark/partitions.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Name, Type, SubType, Offset, Size, Flags
# Note: if you change the phy_init or app partition offset, make sure to change the offset in Kconfig.projbuild
nvs, data, nvs, 0x9000, 0x6000,
phy_init, data, phy, 0xf000, 0x1000,
factory, app, factory, 0x10000, 0x160000,
64 changes: 64 additions & 0 deletions examples/display_lvgl_benchmark/pytest_display_lvgl_benchmark.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# SPDX-FileCopyrightText: 2023-2025 Espressif Systems (Shanghai) CO LTD
# SPDX-License-Identifier: CC0-1.0

import os
import datetime
import pytest
from pytest_embedded import Dut


def write_to_file(board, text):
with open("benchmark_" + board + ".md", "a") as h:
h.write(text)


@pytest.mark.esp_box_3
@pytest.mark.esp32_p4_function_ev_board
@pytest.mark.esp32_c3_lcdkit
@pytest.mark.esp32_s3_eye
@pytest.mark.esp32_s3_lcd_ev_board
@pytest.mark.esp32_s3_lcd_ev_board_2
@pytest.mark.esp32_s3_usb_otg
@pytest.mark.esp_wrover_kit
@pytest.mark.m5dial
@pytest.mark.m5stack_core
@pytest.mark.m5stack_core_2
@pytest.mark.m5stack_core_s3
@pytest.mark.m5stack_core_s3_se
def test_example(dut: Dut, request) -> None:
date = datetime.datetime.now()
board = request.node.callspec.id

# Wait for start benchmark
dut.expect_exact('app_main: Display LVGL demo')
dut.expect_exact('main_task: Returned from app_main()')

try:
os.remove("benchmark_" + board + ".md")
except OSError:
pass

# Write board into file
write_to_file(board, f"# Benchmark for BOARD " + board + "\n\n")
write_to_file(board, f"**DATE:** " + date.strftime('%d.%m.%Y %H:%M') + "\n\n")
# Get LVGL version write it into file
outdata = dut.expect(r'Benchmark Summary \((.*) \)', timeout=200)
write_to_file(board, f"**LVGL version:** " + outdata[1].decode() + "\n\n")
outdata = dut.expect(r'Name, Avg. CPU, Avg. FPS, Avg. time, render time, flush time', timeout=200)
write_to_file(board, f"| Name | Avg. CPU | Avg. FPS | Avg. time | render time | flush time |\n")
write_to_file(board, f"| ---- | :------: | :------: | :-------: | :---------: | :--------: |\n")

# Benchmark lines
for x in range(17):
outdata = dut.expect(r'([\w \.]+),[ ]?(\d+%),[ ]?(\d+),[ ]?(\d+),[ ]?(\d+),[ ]?(\d+)', timeout=200)
write_to_file(board, f"| " +
outdata[1].decode() + " | " +
outdata[2].decode() + " | " +
outdata[3].decode() + " | " +
outdata[4].decode() + " | " +
outdata[5].decode() + " | " +
outdata[6].decode() + " |\n")

write_to_file(board, "\n")
write_to_file(board, "***")
write_to_file(board, "\n\n")
43 changes: 43 additions & 0 deletions examples/display_lvgl_benchmark/sdkconfig.bsp.esp-box
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# This file was generated using idf.py save-defconfig. It can be edited manually.
# Espressif IoT Development Framework (ESP-IDF) Project Minimal Configuration
#
CONFIG_IDF_TARGET="esp32s3"
CONFIG_ESPTOOLPY_FLASHMODE_QIO=y
CONFIG_COMPILER_OPTIMIZATION_PERF=y
CONFIG_PARTITION_TABLE_CUSTOM=y
CONFIG_SPIRAM=y
CONFIG_SPIRAM_MODE_OCT=y
CONFIG_SPIRAM_FETCH_INSTRUCTIONS=y
CONFIG_SPIRAM_RODATA=y
CONFIG_SPIRAM_SPEED_80M=y
CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ_240=y
CONFIG_FREERTOS_HZ=1000
CONFIG_LV_MEM_SIZE_KILOBYTES=48
CONFIG_LV_ATTRIBUTE_FAST_MEM_USE_IRAM=y
CONFIG_LV_FONT_MONTSERRAT_12=y
CONFIG_LV_FONT_MONTSERRAT_16=y
CONFIG_LV_USE_DEMO_WIDGETS=y
CONFIG_LV_USE_DEMO_BENCHMARK=y

# Enable logging
CONFIG_LV_USE_LOG=y
CONFIG_LV_LOG_PRINTF=y

## LVGL8 ##
CONFIG_LV_USE_PERF_MONITOR=y
CONFIG_LV_COLOR_16_SWAP=y
CONFIG_LV_MEM_CUSTOM=y
CONFIG_LV_MEMCPY_MEMSET_STD=y

## LVGL9 ##
CONFIG_LV_CONF_SKIP=y

#CLIB default
CONFIG_LV_USE_CLIB_MALLOC=y
CONFIG_LV_USE_CLIB_SPRINTF=y
CONFIG_LV_USE_CLIB_STRING=y

# Performance monitor
CONFIG_LV_USE_OBSERVER=y
CONFIG_LV_USE_SYSMON=y
CONFIG_LV_USE_PERF_MONITOR=y
44 changes: 44 additions & 0 deletions examples/display_lvgl_benchmark/sdkconfig.bsp.esp-box-3
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# This file was generated using idf.py save-defconfig. It can be edited manually.
# Espressif IoT Development Framework (ESP-IDF) Project Minimal Configuration
#
CONFIG_IDF_TARGET="esp32s3"
CONFIG_ESPTOOLPY_FLASHMODE_QIO=y
CONFIG_COMPILER_OPTIMIZATION_PERF=y
CONFIG_PARTITION_TABLE_CUSTOM=y
CONFIG_SPIRAM=y
CONFIG_SPIRAM_MODE_OCT=y
CONFIG_SPIRAM_FETCH_INSTRUCTIONS=y
CONFIG_SPIRAM_RODATA=y
CONFIG_SPIRAM_SPEED_80M=y
CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ_240=y
CONFIG_FREERTOS_HZ=1000
CONFIG_LV_MEM_SIZE_KILOBYTES=48
CONFIG_LV_ATTRIBUTE_FAST_MEM_USE_IRAM=y
CONFIG_LV_FONT_MONTSERRAT_12=y
CONFIG_LV_FONT_MONTSERRAT_16=y
CONFIG_LV_USE_DEMO_WIDGETS=y
CONFIG_LV_USE_DEMO_BENCHMARK=y
CONFIG_CODEC_I2C_BACKWARD_COMPATIBLE=n

# Enable logging
CONFIG_LV_USE_LOG=y
CONFIG_LV_LOG_PRINTF=y

## LVGL8 ##
CONFIG_LV_USE_PERF_MONITOR=y
CONFIG_LV_COLOR_16_SWAP=y
CONFIG_LV_MEM_CUSTOM=y
CONFIG_LV_MEMCPY_MEMSET_STD=y

## LVGL9 ##
CONFIG_LV_CONF_SKIP=y

#CLIB default
CONFIG_LV_USE_CLIB_MALLOC=y
CONFIG_LV_USE_CLIB_SPRINTF=y
CONFIG_LV_USE_CLIB_STRING=y

# Performance monitor
CONFIG_LV_USE_OBSERVER=y
CONFIG_LV_USE_SYSMON=y
CONFIG_LV_USE_PERF_MONITOR=y
43 changes: 43 additions & 0 deletions examples/display_lvgl_benchmark/sdkconfig.bsp.esp-box-lite
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# This file was generated using idf.py save-defconfig. It can be edited manually.
# Espressif IoT Development Framework (ESP-IDF) Project Minimal Configuration
#
CONFIG_IDF_TARGET="esp32s3"
CONFIG_ESPTOOLPY_FLASHMODE_QIO=y
CONFIG_COMPILER_OPTIMIZATION_PERF=y
CONFIG_PARTITION_TABLE_CUSTOM=y
CONFIG_SPIRAM=y
CONFIG_SPIRAM_MODE_OCT=y
CONFIG_SPIRAM_FETCH_INSTRUCTIONS=y
CONFIG_SPIRAM_RODATA=y
CONFIG_SPIRAM_SPEED_80M=y
CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ_240=y
CONFIG_FREERTOS_HZ=1000
CONFIG_LV_MEM_SIZE_KILOBYTES=48
CONFIG_LV_ATTRIBUTE_FAST_MEM_USE_IRAM=y
CONFIG_LV_FONT_MONTSERRAT_12=y
CONFIG_LV_FONT_MONTSERRAT_16=y
CONFIG_LV_USE_DEMO_WIDGETS=y
CONFIG_LV_USE_DEMO_BENCHMARK=y

# Enable logging
CONFIG_LV_USE_LOG=y
CONFIG_LV_LOG_PRINTF=y

## LVGL8 ##
CONFIG_LV_USE_PERF_MONITOR=y
CONFIG_LV_COLOR_16_SWAP=y
CONFIG_LV_MEM_CUSTOM=y
CONFIG_LV_MEMCPY_MEMSET_STD=y

## LVGL9 ##
CONFIG_LV_CONF_SKIP=y

#CLIB default
CONFIG_LV_USE_CLIB_MALLOC=y
CONFIG_LV_USE_CLIB_SPRINTF=y
CONFIG_LV_USE_CLIB_STRING=y

# Performance monitor
CONFIG_LV_USE_OBSERVER=y
CONFIG_LV_USE_SYSMON=y
CONFIG_LV_USE_PERF_MONITOR=y
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# This file was generated using idf.py save-defconfig. It can be edited manually.
# Espressif IoT Development Framework (ESP-IDF) Project Minimal Configuration
#
CONFIG_IDF_TARGET="esp32p4"
CONFIG_ESPTOOLPY_FLASHMODE_QIO=y
CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y
CONFIG_PARTITION_TABLE_CUSTOM=y
CONFIG_COMPILER_OPTIMIZATION_PERF=y
CONFIG_SPIRAM=y
CONFIG_SPIRAM_MODE_OCT=y
CONFIG_SPIRAM_FETCH_INSTRUCTIONS=y
CONFIG_SPIRAM_RODATA=y
CONFIG_SPIRAM_SPEED_80M=y
CONFIG_FREERTOS_HZ=1000
CONFIG_BSP_LCD_RGB_BUFFER_NUMS=2
CONFIG_BSP_LCD_RGB_BOUNCE_BUFFER_MODE=y
CONFIG_BSP_DISPLAY_LVGL_AVOID_TEAR=y
CONFIG_BSP_DISPLAY_LVGL_DIRECT_MODE=y
CONFIG_LV_FONT_MONTSERRAT_12=y
CONFIG_LV_FONT_MONTSERRAT_16=y
CONFIG_LV_FONT_MONTSERRAT_24=y
CONFIG_LV_USE_DEMO_WIDGETS=y
CONFIG_LV_USE_DEMO_BENCHMARK=y
CONFIG_LV_ATTRIBUTE_FAST_MEM_USE_IRAM=y
CONFIG_LV_DISP_DEF_REFR_PERIOD=10

CONFIG_SPIRAM=y
CONFIG_SPIRAM_MODE_HEX=y
CONFIG_SPIRAM_SPEED_200M=y
CONFIG_IDF_EXPERIMENTAL_FEATURES=y

# Enable logging
CONFIG_LV_USE_LOG=y
CONFIG_LV_LOG_PRINTF=y

## LVGL8 ##
CONFIG_LV_MEM_SIZE_KILOBYTES=48
CONFIG_LV_USE_PERF_MONITOR=y

## LVGL9 ##
CONFIG_LV_CONF_SKIP=y

#CLIB default
CONFIG_LV_USE_CLIB_MALLOC=y
CONFIG_LV_USE_CLIB_SPRINTF=y
CONFIG_LV_USE_CLIB_STRING=y

# Performance monitor
CONFIG_LV_USE_OBSERVER=y
CONFIG_LV_USE_SYSMON=y
CONFIG_LV_USE_PERF_MONITOR=y
Loading

0 comments on commit 96f0307

Please sign in to comment.