mirror of
https://github.com/espressif/esp-idf.git
synced 2026-10-01 18:50:34 +03:00
feat(size_metrics): add size metrics test apps
Add test apps for binary size tracking: - esp_timer size_metrics app with minimal/full sdkconfig variants - minimal_baseline app to establish the platform binary size floor
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
# Size metrics test app for esp_timer component
|
||||
cmake_minimum_required(VERSION 3.22)
|
||||
|
||||
list(PREPEND SDKCONFIG_DEFAULTS
|
||||
"$ENV{IDF_PATH}/tools/test_apps/configs/sdkconfig.size_metrics"
|
||||
"sdkconfig.defaults")
|
||||
|
||||
# "Trim" the build. Include the minimal set of components, main, and anything it depends on.
|
||||
set(COMPONENTS main)
|
||||
|
||||
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
||||
project(size_metrics)
|
||||
@@ -0,0 +1,2 @@
|
||||
| Supported Targets | ESP32 | ESP32-C6 |
|
||||
| ----------------- | ----- | -------- |
|
||||
@@ -0,0 +1,3 @@
|
||||
idf_component_register(SRCS "main.c"
|
||||
PRIV_REQUIRES esp_timer
|
||||
WHOLE_ARCHIVE)
|
||||
@@ -0,0 +1,18 @@
|
||||
menu "Size Metrics Test App Configuration"
|
||||
|
||||
choice SIZE_METRICS_FUNCTION_SET
|
||||
prompt "Function set to compile"
|
||||
default SIZE_METRICS_FUNCTION_SET_MINIMAL
|
||||
help
|
||||
Select which set of functions to compile for size metrics comparison.
|
||||
Minimal set includes only basic functions, full set includes all features.
|
||||
|
||||
config SIZE_METRICS_FUNCTION_SET_MINIMAL
|
||||
bool "Minimal function set"
|
||||
|
||||
config SIZE_METRICS_FUNCTION_SET_FULL
|
||||
bool "Full function set"
|
||||
|
||||
endchoice
|
||||
|
||||
endmenu
|
||||
@@ -0,0 +1,85 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2026 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Unlicense OR CC0-1.0
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "esp_timer.h"
|
||||
#include "sdkconfig.h"
|
||||
|
||||
#if CONFIG_SIZE_METRICS_FUNCTION_SET_MINIMAL
|
||||
// Minimal function set - basic timer operations only
|
||||
static void minimal_timer_callback(void* arg)
|
||||
{
|
||||
// Minimal callback implementation
|
||||
}
|
||||
|
||||
static void minimal_functions(void)
|
||||
{
|
||||
esp_timer_handle_t timer;
|
||||
esp_timer_create_args_t timer_args = {
|
||||
.callback = minimal_timer_callback,
|
||||
.name = "minimal_timer"
|
||||
};
|
||||
esp_timer_create(&timer_args, &timer);
|
||||
esp_timer_start_once(timer, 1000);
|
||||
esp_timer_stop(timer);
|
||||
esp_timer_delete(timer);
|
||||
}
|
||||
#endif // CONFIG_SIZE_METRICS_FUNCTION_SET_MINIMAL
|
||||
|
||||
#if CONFIG_SIZE_METRICS_FUNCTION_SET_FULL
|
||||
// Full function set - all timer features
|
||||
static void full_timer_callback(void* arg)
|
||||
{
|
||||
// Full callback implementation with more features
|
||||
}
|
||||
|
||||
static void full_periodic_timer_callback(void* arg)
|
||||
{
|
||||
// Periodic timer callback
|
||||
}
|
||||
|
||||
static void full_functions(void)
|
||||
{
|
||||
esp_timer_handle_t oneshot_timer;
|
||||
esp_timer_handle_t periodic_timer;
|
||||
|
||||
// One-shot timer
|
||||
esp_timer_create_args_t oneshot_args = {
|
||||
.callback = full_timer_callback,
|
||||
.name = "oneshot_timer"
|
||||
};
|
||||
esp_timer_create(&oneshot_args, &oneshot_timer);
|
||||
esp_timer_start_once(oneshot_timer, 1000);
|
||||
|
||||
// Periodic timer
|
||||
esp_timer_create_args_t periodic_args = {
|
||||
.callback = full_periodic_timer_callback,
|
||||
.name = "periodic_timer"
|
||||
};
|
||||
esp_timer_create(&periodic_args, &periodic_timer);
|
||||
esp_timer_start_periodic(periodic_timer, 5000);
|
||||
|
||||
// Timer operations
|
||||
esp_timer_stop(oneshot_timer);
|
||||
esp_timer_stop(periodic_timer);
|
||||
esp_timer_delete(oneshot_timer);
|
||||
esp_timer_delete(periodic_timer);
|
||||
}
|
||||
#endif // CONFIG_SIZE_METRICS_FUNCTION_SET_FULL
|
||||
|
||||
void app_main(void)
|
||||
{
|
||||
printf("size_metrics app_main started\n");
|
||||
|
||||
#if CONFIG_SIZE_METRICS_FUNCTION_SET_MINIMAL
|
||||
minimal_functions();
|
||||
#endif
|
||||
|
||||
#if CONFIG_SIZE_METRICS_FUNCTION_SET_FULL
|
||||
full_functions();
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
# SPDX-FileCopyrightText: 2026 Espressif Systems (Shanghai) CO LTD
|
||||
# SPDX-License-Identifier: Unlicense OR CC0-1.0
|
||||
import pytest
|
||||
from pytest_embedded_idf.dut import IdfDut
|
||||
from pytest_embedded_idf.utils import idf_parametrize
|
||||
|
||||
|
||||
@pytest.mark.generic
|
||||
@pytest.mark.parametrize('config', ['minimal', 'full'], indirect=True)
|
||||
@idf_parametrize('target', ['esp32', 'esp32c6'], indirect=['target'])
|
||||
def test_esp_timer_size_metrics_boots(dut: IdfDut) -> None:
|
||||
dut.expect_exact('size_metrics app_main started', timeout=30)
|
||||
@@ -0,0 +1,3 @@
|
||||
# Full configuration for size metrics
|
||||
CONFIG_SIZE_METRICS_FUNCTION_SET_MINIMAL=n
|
||||
CONFIG_SIZE_METRICS_FUNCTION_SET_FULL=y
|
||||
@@ -0,0 +1,3 @@
|
||||
# Minimal configuration for size metrics
|
||||
CONFIG_SIZE_METRICS_FUNCTION_SET_MINIMAL=y
|
||||
CONFIG_SIZE_METRICS_FUNCTION_SET_FULL=n
|
||||
@@ -0,0 +1,2 @@
|
||||
# App-specific defaults for esp_timer size metrics
|
||||
CONFIG_ESP_TIMER_PROFILING=n
|
||||
Reference in New Issue
Block a user