mirror of
https://github.com/esphome/esphome.git
synced 2026-09-01 18:46:02 +00:00
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.
27 lines
566 B
C++
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
|