Skip to content

Commit d8b355f

Browse files
committed
ci(runner): Add benchmark example and print benchmark results
1 parent 740a580 commit d8b355f

19 files changed

+834
-11
lines changed

.github/workflows/build-run-applications.yml

Lines changed: 102 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,28 +5,56 @@ name: Build ESP-BSP apps
55

66
on:
77
pull_request:
8-
types: [opened, reopened, synchronize]
8+
types: [opened, reopened, synchronize, labeled]
9+
push:
10+
branches:
11+
- master
12+
workflow_dispatch:
13+
inputs:
14+
WFType:
15+
description: 'Workflow type'
16+
required: true
17+
default: 'Build + Tests'
18+
type: choice
19+
options:
20+
- Build + Tests
21+
- Build + Tests + Benchmark
922

1023
jobs:
1124
build:
1225
strategy:
1326
matrix:
1427
include:
1528
- idf_ver: "latest"
16-
parallel_count: 5
29+
parallel_count: 10
1730
parallel_index: 1
1831
- idf_ver: "latest"
19-
parallel_count: 5
32+
parallel_count: 10
2033
parallel_index: 2
2134
- idf_ver: "latest"
22-
parallel_count: 5
35+
parallel_count: 10
2336
parallel_index: 3
2437
- idf_ver: "latest"
25-
parallel_count: 5
38+
parallel_count: 10
2639
parallel_index: 4
2740
- idf_ver: "latest"
28-
parallel_count: 5
41+
parallel_count: 10
2942
parallel_index: 5
43+
- idf_ver: "latest"
44+
parallel_count: 10
45+
parallel_index: 6
46+
- idf_ver: "latest"
47+
parallel_count: 10
48+
parallel_index: 7
49+
- idf_ver: "latest"
50+
parallel_count: 10
51+
parallel_index: 8
52+
- idf_ver: "latest"
53+
parallel_count: 10
54+
parallel_index: 9
55+
- idf_ver: "latest"
56+
parallel_count: 10
57+
parallel_index: 10
3058
- idf_ver: "release-v5.1"
3159
parallel_count: 2
3260
parallel_index: 1
@@ -89,7 +117,7 @@ jobs:
89117
90118
run-target:
91119
name: Run apps
92-
if: github.repository_owner == 'espressif' && needs.prepare.outputs.build_only != '1'
120+
if: github.repository_owner == 'espressif' && !contains(github.event.pull_request.labels.*.name, 'Build only')
93121
needs: build
94122
strategy:
95123
fail-fast: false
@@ -151,6 +179,7 @@ jobs:
151179
target: "esp32s3"
152180
env:
153181
TEST_RESULT_NAME: test_results_${{ matrix.runner.target }}_${{ matrix.runner.marker }}_${{ matrix.idf_ver }}
182+
BENCHMARK_RESULT_NAME: benchmark_${{ matrix.runner.target }}_${{ matrix.runner.marker }}_${{ matrix.idf_ver }}
154183
TEST_RESULT_FILE: test_results_${{ matrix.runner.target }}_${{ matrix.runner.marker }}_${{ matrix.idf_ver }}.xml
155184
runs-on: [self-hosted, Linux, bspwall]
156185
container:
@@ -165,22 +194,58 @@ jobs:
165194
- name: Install Python packages
166195
env:
167196
PIP_EXTRA_INDEX_URL: "https://dl.espressif.com/pypi/"
168-
run: pip install --prefer-binary cryptography pytest-embedded pytest-embedded-serial-esp pytest-embedded-idf pytest-custom_exit_code
197+
run: |
198+
echo "PYTEST_BENCHMARK_IGNORE=--ignore='examples/display_lvgl_benchmark'" >> $GITHUB_ENV
199+
pip install --prefer-binary cryptography pytest-embedded pytest-embedded-serial-esp pytest-embedded-idf pytest-custom_exit_code
200+
- name: Download latest results
201+
uses: actions/download-artifact@v4
202+
with:
203+
pattern: benchmark_*
204+
path: benchmark/
205+
- name: Set ignores
206+
if: contains(github.event.pull_request.labels.*.name, 'Run benchmark') || contains(inputs.WFType, 'Build + Tests + Benchmark') || github.ref_name == 'master'
207+
id: set_ignores
208+
run: |
209+
echo "PYTEST_BENCHMARK_IGNORE=" >> $GITHUB_ENV
210+
- name: Pull
211+
run: |
212+
git pull --rebase origin ${{ github.head_ref }} || echo "No remote changes to rebase"
169213
- name: Run apps
170214
run: |
171-
pytest --suppress-no-test-exit-code --ignore-glob '*/managed_components/*' --ignore=.github --junit-xml=${{ env.TEST_RESULT_FILE }} --target=${{ matrix.runner.target }} -m ${{ matrix.runner.marker }} --build-dir=build_${{ matrix.runner.runs-on }}
215+
pytest --suppress-no-test-exit-code --ignore-glob '*/managed_components/*' --ignore=.github ${{ env.PYTEST_BENCHMARK_IGNORE }} --junit-xml=${{ env.TEST_RESULT_FILE }} --target=${{ matrix.runner.target }} -m ${{ matrix.runner.marker }} --build-dir=build_${{ matrix.runner.runs-on }}
172216
- name: Upload test results
173217
uses: actions/upload-artifact@v4
174218
if: always()
175219
with:
176220
name: ${{ env.TEST_RESULT_NAME }}
177-
path: ${{ env.TEST_RESULT_FILE }}
221+
path: |
222+
${{ env.TEST_RESULT_FILE }}
223+
benchmark_*.md
224+
benchmark_*.json
225+
benchmark.json
226+
- name: Upload test results
227+
uses: actions/upload-artifact@v4
228+
if: github.ref_name == 'master'
229+
with:
230+
name: ${{ env.BENCHMARK_RESULT_NAME }}
231+
path: |
232+
benchmark_*.md
233+
benchmark_*.json
234+
- name: Update benchmark release
235+
uses: pyTooling/Actions/releaser@r0
236+
if: github.ref_name == 'master'
237+
with:
238+
token: ${{ secrets.GITHUB_TOKEN }}
239+
files: |
240+
benchmark_*.json
241+
benchmark_*.md
242+
tag: benchmark-latest
178243

179244
publish-results:
180245
name: Publish Test results
181246
needs:
182247
- run-target
183-
if: github.repository_owner == 'espressif' && always() && github.event_name == 'pull_request' && needs.prepare.outputs.build_only == '0'
248+
if: github.repository_owner == 'espressif' && always() && github.event_name == 'pull_request' && !contains(github.event.pull_request.labels.*.name, 'Build only')
184249
runs-on: ubuntu-22.04
185250
steps:
186251
- name: Download Test results
@@ -192,3 +257,29 @@ jobs:
192257
uses: EnricoMi/publish-unit-test-result-action@v2
193258
with:
194259
files: test_results/**/*.xml
260+
- name: Find test result files
261+
id: find_files
262+
run: |
263+
OUTPUT_FILE="combined_benchmarks.md"
264+
echo "" > $OUTPUT_FILE
265+
python <<EOF
266+
import glob
267+
268+
files = sorted(glob.glob("test_results/**/benchmark_*.md"))
269+
print(files)
270+
output_file = "combined_benchmarks.md"
271+
272+
with open(output_file, "w", encoding="utf-8") as outfile:
273+
for file in files:
274+
with open(file, "r", encoding="utf-8") as infile:
275+
outfile.write(infile.read() + "\n\n")
276+
277+
print(f"Merged {len(files)} files into {output_file}")
278+
EOF
279+
280+
echo "output_file=$OUTPUT_FILE" >> "$GITHUB_ENV"
281+
- name: Comment PR
282+
uses: thollander/actions-comment-pull-request@v3
283+
with:
284+
comment-tag: benchmark_results
285+
file-path: ${{ env.output_file }}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# For more information about build system see
2+
# https://docs.espressif.com/projects/esp-idf/en/latest/api-guides/build-system.html
3+
# The following five lines of boilerplate have to be in your project's
4+
# CMakeLists in this exact order for cmake to work correctly
5+
cmake_minimum_required(VERSION 3.5)
6+
7+
set(COMPONENTS main) # "Trim" the build. Include the minimal set of components; main and anything it depends on.
8+
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
9+
add_compile_options("-Wno-attributes") # For LVGL code
10+
project(display_lvgl_benchmark)
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Display LVGL Benchmark
2+
3+
This example shows LVGL internal benchmark demo.
4+
5+
## How to use the example
6+
7+
### Hardware Required
8+
9+
* ESP32-S3-LCD-EV-Board or ESP32-S3-LCD-EV-Board-2
10+
* USB-C Cable
11+
12+
### Compile and flash
13+
14+
```
15+
idf.py -p COMx build flash monitor
16+
```
17+
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
set(LV_DEMO_DIR "")
2+
set(LV_DEMOS_SOURCES "")
3+
if(CONFIG_LV_USE_DEMO_BENCHMARK)
4+
list(APPEND LV_DEMO_DIR ../managed_components/lvgl__lvgl/demos)
5+
file(GLOB_RECURSE LV_DEMOS_SOURCES ${LV_DEMO_DIR}/*.c)
6+
endif()
7+
8+
idf_component_register(
9+
SRCS "main.c" ${LV_DEMOS_SOURCES}
10+
INCLUDE_DIRS "." ${LV_DEMO_DIR})
11+
12+
if(CONFIG_LV_USE_DEMO_BENCHMARK)
13+
set_source_files_properties(
14+
${LV_DEMOS_SOURCES}
15+
PROPERTIES COMPILE_OPTIONS
16+
-DLV_LVGL_H_INCLUDE_SIMPLE)
17+
endif()
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
description: BSP Display rotation example
2+
dependencies:
3+
esp32_p4_function_ev_board:
4+
version: '*'
5+
override_path: ../../../bsp/esp32_p4_function_ev_board
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/*
2+
* SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD
3+
*
4+
* SPDX-License-Identifier: CC0-1.0
5+
*/
6+
7+
#include "freertos/FreeRTOS.h"
8+
#include "freertos/task.h"
9+
#include "esp_log.h"
10+
11+
#include "lv_demos.h"
12+
#include "bsp/esp-bsp.h"
13+
14+
static char *TAG = "app_main";
15+
16+
#define LOG_MEM_INFO (0)
17+
18+
void app_main(void)
19+
{
20+
/* Initialize display and LVGL */
21+
#if defined(BSP_LCD_SUB_BOARD_2_H_RES)
22+
/* Only for esp32_s3_lcd_ev_board */
23+
bsp_display_cfg_t cfg = {
24+
.lvgl_port_cfg = ESP_LVGL_PORT_INIT_CONFIG(),
25+
};
26+
cfg.lvgl_port_cfg.task_stack = 10000;
27+
bsp_display_start_with_config(&cfg);
28+
#else
29+
bsp_display_start();
30+
#endif
31+
32+
/* Set display brightness to 100% */
33+
bsp_display_backlight_on();
34+
35+
ESP_LOGI(TAG, "Display LVGL demo");
36+
bsp_display_lock(0);
37+
lv_demo_benchmark(); /* A demo to measure the performance of LVGL or to compare different settings. */
38+
bsp_display_unlock();
39+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Name, Type, SubType, Offset, Size, Flags
2+
# Note: if you change the phy_init or app partition offset, make sure to change the offset in Kconfig.projbuild
3+
nvs, data, nvs, 0x9000, 0x6000,
4+
phy_init, data, phy, 0xf000, 0x1000,
5+
factory, app, factory, 0x10000, 0x160000,

0 commit comments

Comments
 (0)