Add core benchmarks dir, fix core pseudo-component, use simulation mode

- Move scheduler/loop/helpers benchmarks to tests/benchmarks/components/core/
- Add random_float and random_uint32 benchmarks (from ol.yaml)
- Fix core pseudo-component crash: skip components where get_component()
  returns None when adding dependencies to config
- Use CodSpeed simulation mode (CPU instruction counting) for reproducible
  CI results instead of walltime
This commit is contained in:
J. Nick Koston
2026-03-16 20:49:48 -10:00
parent d9cab03c09
commit 9c148da76a
5 changed files with 30 additions and 1 deletions
+1
View File
@@ -339,6 +339,7 @@ jobs:
with:
run: ${{ steps.build.outputs.binary }}
token: ${{ secrets.CODSPEED_TOKEN }}
mode: simulation
clang-tidy-single:
name: ${{ matrix.name }}
+3 -1
View File
@@ -248,7 +248,9 @@ def compile_and_get_binary(
domain_list = config.setdefault(domain, [])
CORE.testing_ensure_platform_registered(domain)
domain_list.append({CONF_PLATFORM: component})
else:
# Skip "core" — it's a pseudo-component handled by the build
# system, not a real loadable component (get_component returns None)
elif get_component(component_name) is not None:
config.setdefault(component_name, [])
# Register platforms from the extra config (benchmark.yaml) so
@@ -0,0 +1,26 @@
#include <benchmark/benchmark.h>
#include "esphome/core/helpers.h"
namespace esphome::benchmarks {
// --- random_float() ---
// Ported from ol.yaml:148 "Random Float Benchmark"
static void BM_RandomFloat(benchmark::State &state) {
for (auto _ : state) {
benchmark::DoNotOptimize(random_float());
}
}
BENCHMARK(BM_RandomFloat);
// --- random_uint32() ---
static void BM_RandomUint32(benchmark::State &state) {
for (auto _ : state) {
benchmark::DoNotOptimize(random_uint32());
}
}
BENCHMARK(BM_RandomUint32);
} // namespace esphome::benchmarks