Commit Graph

27 Commits

Author SHA1 Message Date
J. Nick Koston 8c0e5e9d9a [api] Address Copilot review on proxy benchmarks PR
- Make UARTFlushResult in the serial_proxy stub a scoped enum class with
  matching scoped enumerator return in flush_port(), so the stub
  signature lines up with the real esphome::uart::UARTFlushResult.
- Replace heap-leaking lazy-init in get_ir_timings_100() with a
  function-local static const std::vector populated by a regular helper
  function. Same lazy-init behavior, no leak in valgrind/ASan, no lambda
  IIFE.
- Emit field 6 (modulation = 1) in build_infrared_rf_transmit_wire() so
  the bytes match the documented field list and the decode benchmark
  also exercises the field-6 decode_varint path.
2026-04-29 22:40:45 -05:00
J. Nick Koston a0532d657f [api] Drop escape() helper and return-by-value APIBuffer in proxy decode benchmarks
Simplifies the decode benchmarks to mirror the encode pattern more
closely: no per-iteration asm volatile barrier, no return-by-value of
APIBuffer through encode_message_for_proxy. CodSpeed callgrind has been
crashing inside Decode_ZWaveProxyFrame and the previous setup was the
main thing it had that the (passing) Encode_ZWaveProxyFrame did not.
2026-04-29 21:46:32 -05:00
J. Nick Koston 483d294ef6 [api] Move proxy message benchmarks into bench_proto_proxy.cpp
Splitting these out from bench_proto_encode.cpp and bench_proto_decode.cpp
moves them to the end of the linker's static-init order. CodSpeed's
callgrind runner has been segfaulting immediately after measuring the
last existing decode benchmark (Decode_SwitchCommandRequest), and
isolating the new code into its own translation unit lets us see whether
the crash is triggered by one of the new benchmarks or by something
about the new USE_*_PROXY/USE_INFRARED/USE_RADIO_FREQUENCY defines
changing how api_pb2.cpp compiles.
2026-04-29 21:38:01 -05:00
J. Nick Koston f841de0664 [api] Avoid lambda IIFE and per-byte APIBuffer growth in proxy benchmarks
The InfraredRFReceiveEvent encode benchmark used a C++17 lambda IIFE
(`[]{...}()`) to seed a function-static vector, and the
InfraredRFTransmitRawTimingsRequest decode benchmark grew its APIBuffer
one byte at a time (~210 grow_() calls), each allocating a fresh
exact-fit buffer and memcpy'ing the prior contents. Both patterns are
fine under direct execution but appear to hit a CodSpeed/valgrind
edge case during the simulated benchmark run.

Switch to a plain heap-init pattern for the vector and build the wire
bytes into a stack array first, then resize+memcpy into the APIBuffer
once.
2026-04-29 21:25:46 -05:00
J. Nick Koston 4c027e87ba [api] Add encode/decode benchmarks for Z-Wave, IR/RF, and serial proxy messages
Mirrors the existing BluetoothLERawAdvertisementsResponse benchmarks for
the remaining proxy message families: ZWaveProxyFrame/ZWaveProxyRequest,
SerialProxyDataReceived/SerialProxyWriteRequest, and
InfraredRFReceiveEvent/InfraredRFTransmitRawTimingsRequest.

Adds minimal stub headers under tests/benchmarks/stubs/ for the
zwave_proxy, infrared, radio_frequency, and serial_proxy components so
api_connection.cpp compiles without dragging in their UART/RMT/BLE
hardware dependencies.
2026-04-29 21:07:39 -05:00
J. Nick Koston 4f69c3b850 [benchmark] Add SubscribeLogsResponse encode benchmarks (#15696) 2026-04-13 02:03:53 -05:00
J. Nick Koston 576d89a82a [api] Peel first write iteration, inline socket writes, zero-gap batch encoding (#15063) 2026-04-08 11:05:53 -10:00
J. Nick Koston a8b7c7a4ac [core] Add TemplatableFn for 4-byte function-pointer templatable storage (#15545)
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2026-04-08 08:38:00 -04:00
J. Nick Koston f193bab60b [api] Add ListEntities benchmarks for sensor, binary_sensor, and light (#15427) 2026-04-05 13:25:50 -10:00
J. Nick Koston f2a0d9943d [benchmarks] Add host platform benchmarks for text_sensor and button (#15407) 2026-04-03 08:27:55 -10:00
J. Nick Koston ea0227a206 [benchmarks] Add host platform benchmarks for number, select, and switch (#15405) 2026-04-03 08:27:44 -10:00
J. Nick Koston bcc7b8f490 [api] Add send_sensor_state benchmarks (#15352) 2026-04-01 16:12:02 -10:00
J. Nick Koston 8688ef7125 [benchmark] Fix decode benchmarks being optimized away by compiler (#15293) 2026-03-30 08:24:48 -10:00
J. Nick Koston 8a802ca666 [benchmark] Add BLE raw advertisement proto encode benchmarks (#15289) 2026-03-29 11:54:07 -10:00
J. Nick Koston 240e53afce [fan] Add benchmarks for fan component (#15210) 2026-03-26 14:35:09 -10:00
J. Nick Koston 02e23eb386 [benchmark] Add light call and publish benchmarks (#15176) 2026-03-26 07:33:10 -10:00
J. Nick Koston 6898284361 [benchmark] Add cover publish_state and call benchmarks (#15179) 2026-03-26 07:32:54 -10:00
J. Nick Koston f3a31be6d0 [benchmark] Add climate publish_state and call benchmarks (#15180) 2026-03-26 07:32:39 -10:00
J. Nick Koston 010516aef2 [benchmark] Add sensor publish_state benchmarks (#15034) 2026-03-25 07:33:17 -10:00
J. Nick Koston 690dc324c9 [logger] Move task log buffer storage to BSS (#15153) 2026-03-25 00:52:37 +00:00
J. Nick Koston a0d0516b22 [benchmark] Add noise handshake benchmark (#15039) 2026-03-23 13:40:41 -10:00
J. Nick Koston 597bb18543 [benchmark] Add binary sensor publish and sensor filter benchmarks (#15035) 2026-03-23 16:30:57 +13:00
J. Nick Koston 593dbc9e67 [logger] Fix unit test and benchmark Logger constructor calls (#15085) 2026-03-23 09:50:58 +13:00
J. Nick Koston 86ec218f75 [benchmark] Add plaintext API frame write benchmarks (#15036) 2026-03-21 13:15:35 -10:00
J. Nick Koston 1920d8a887 [benchmark] Add noise encryption benchmarks (#15037) 2026-03-20 17:35:17 -10:00
Javier Peletier 0c5f055d45 [core] cpp tests: Allow customizing code generation during tests (#14681)
Co-authored-by: J. Nick Koston <nick@home-assistant.io>
Co-authored-by: J. Nick Koston <nick@koston.org>
2026-03-18 00:16:01 +00:00
J. Nick Koston 1670f04a87 [core] Add CodSpeed C++ benchmarks for protobuf, main loop, and helpers (#14878) 2026-03-17 12:29:38 -10:00