Remove BM_ prefix, drop application loop benchmark, fix core includes

- Remove BM_ prefix from all benchmark names (unnecessary convention)
- Remove bench_application_loop.cpp (App needs pre_setup/setup which
  requires full code generation; will revisit as integration benchmark)
- Fix extra_include_dirs to use os.path.relpath for sibling directories
This commit is contained in:
J. Nick Koston
2026-03-16 22:27:03 -10:00
parent 456a7d740e
commit a92147e1c9
6 changed files with 55 additions and 59 deletions
@@ -7,7 +7,7 @@ namespace esphome::api::benchmarks {
// --- ProtoVarInt::parse() benchmarks ---
static void BM_ProtoVarInt_Parse_SingleByte(benchmark::State &state) {
static void ProtoVarInt_Parse_SingleByte(benchmark::State &state) {
// Single-byte varint (0-127) — the most common case (fast path)
uint8_t buf[] = {0x42}; // value = 66
@@ -16,9 +16,9 @@ static void BM_ProtoVarInt_Parse_SingleByte(benchmark::State &state) {
benchmark::DoNotOptimize(result);
}
}
BENCHMARK(BM_ProtoVarInt_Parse_SingleByte);
BENCHMARK(ProtoVarInt_Parse_SingleByte);
static void BM_ProtoVarInt_Parse_TwoByte(benchmark::State &state) {
static void ProtoVarInt_Parse_TwoByte(benchmark::State &state) {
// Two-byte varint (128-16383)
uint8_t buf[] = {0x80, 0x01}; // value = 128
@@ -27,9 +27,9 @@ static void BM_ProtoVarInt_Parse_TwoByte(benchmark::State &state) {
benchmark::DoNotOptimize(result);
}
}
BENCHMARK(BM_ProtoVarInt_Parse_TwoByte);
BENCHMARK(ProtoVarInt_Parse_TwoByte);
static void BM_ProtoVarInt_Parse_FiveByte(benchmark::State &state) {
static void ProtoVarInt_Parse_FiveByte(benchmark::State &state) {
// Five-byte varint (max uint32 = 4294967295)
uint8_t buf[] = {0xFF, 0xFF, 0xFF, 0xFF, 0x0F};
@@ -38,11 +38,11 @@ static void BM_ProtoVarInt_Parse_FiveByte(benchmark::State &state) {
benchmark::DoNotOptimize(result);
}
}
BENCHMARK(BM_ProtoVarInt_Parse_FiveByte);
BENCHMARK(ProtoVarInt_Parse_FiveByte);
// --- Varint encoding benchmarks ---
static void BM_Encode_Varint_Small(benchmark::State &state) {
static void Encode_Varint_Small(benchmark::State &state) {
// Value < 128 — single byte fast path
APIBuffer buffer;
buffer.resize(16);
@@ -53,9 +53,9 @@ static void BM_Encode_Varint_Small(benchmark::State &state) {
benchmark::DoNotOptimize(buffer.data());
}
}
BENCHMARK(BM_Encode_Varint_Small);
BENCHMARK(Encode_Varint_Small);
static void BM_Encode_Varint_Large(benchmark::State &state) {
static void Encode_Varint_Large(benchmark::State &state) {
// Value > 128 — multi-byte slow path
APIBuffer buffer;
buffer.resize(16);
@@ -66,9 +66,9 @@ static void BM_Encode_Varint_Large(benchmark::State &state) {
benchmark::DoNotOptimize(buffer.data());
}
}
BENCHMARK(BM_Encode_Varint_Large);
BENCHMARK(Encode_Varint_Large);
static void BM_Encode_Varint_MaxUint32(benchmark::State &state) {
static void Encode_Varint_MaxUint32(benchmark::State &state) {
APIBuffer buffer;
buffer.resize(16);
@@ -78,22 +78,22 @@ static void BM_Encode_Varint_MaxUint32(benchmark::State &state) {
benchmark::DoNotOptimize(buffer.data());
}
}
BENCHMARK(BM_Encode_Varint_MaxUint32);
BENCHMARK(Encode_Varint_MaxUint32);
// --- ProtoSize::varint() benchmarks ---
static void BM_ProtoSize_Varint_Small(benchmark::State &state) {
static void ProtoSize_Varint_Small(benchmark::State &state) {
for (auto _ : state) {
benchmark::DoNotOptimize(ProtoSize::varint(42));
}
}
BENCHMARK(BM_ProtoSize_Varint_Small);
BENCHMARK(ProtoSize_Varint_Small);
static void BM_ProtoSize_Varint_Large(benchmark::State &state) {
static void ProtoSize_Varint_Large(benchmark::State &state) {
for (auto _ : state) {
benchmark::DoNotOptimize(ProtoSize::varint(0xFFFFFFFF));
}
}
BENCHMARK(BM_ProtoSize_Varint_Large);
BENCHMARK(ProtoSize_Varint_Large);
} // namespace esphome::api::benchmarks