Files
esphome/tests/benchmarks/core/bench_helpers.cpp
T
J. Nick Koston a6219434b9 Move core benchmarks to tests/benchmarks/core/
Core is not a component — its benchmarks belong in tests/benchmarks/core/
not tests/benchmarks/components/core/. Add extra_include_dirs parameter
to build_and_run to support non-component benchmark directories.
2026-03-16 20:52:53 -10:00

27 lines
566 B
C++

#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