mirror of
https://github.com/esphome/esphome.git
synced 2026-09-17 18:18:43 +00:00
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:
@@ -339,6 +339,7 @@ jobs:
|
||||
with:
|
||||
run: ${{ steps.build.outputs.binary }}
|
||||
token: ${{ secrets.CODSPEED_TOKEN }}
|
||||
mode: simulation
|
||||
|
||||
clang-tidy-single:
|
||||
name: ${{ matrix.name }}
|
||||
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user