Files
esphome/tests/benchmarks/components/main.cpp
J. Nick Koston 593dbc9e67
Some checks are pending
CI / Create common environment (push) Waiting to run
CI / Check pylint (push) Blocked by required conditions
CI / Run script/ci-custom (push) Blocked by required conditions
CI / Run pytest (macOS-latest, 3.11) (push) Blocked by required conditions
CI / Run pytest (macOS-latest, 3.14) (push) Blocked by required conditions
CI / Run pytest (ubuntu-latest, 3.11) (push) Blocked by required conditions
CI / Run pytest (ubuntu-latest, 3.13) (push) Blocked by required conditions
CI / Run pytest (ubuntu-latest, 3.14) (push) Blocked by required conditions
CI / Run pytest (windows-latest, 3.11) (push) Blocked by required conditions
CI / Run pytest (windows-latest, 3.14) (push) Blocked by required conditions
CI / Determine which jobs to run (push) Blocked by required conditions
CI / Run integration tests (push) Blocked by required conditions
CI / Run C++ unit tests (push) Blocked by required conditions
CI / Run CodSpeed benchmarks (push) Blocked by required conditions
CI / Run script/clang-tidy for ESP32 IDF (push) Blocked by required conditions
CI / Run script/clang-tidy for ESP8266 (push) Blocked by required conditions
CI / Run script/clang-tidy for ZEPHYR (push) Blocked by required conditions
CI / Run script/clang-tidy for ESP32 Arduino (push) Blocked by required conditions
CI / Run script/clang-tidy for ESP32 Arduino 1/4 (push) Blocked by required conditions
CI / Run script/clang-tidy for ESP32 Arduino 2/4 (push) Blocked by required conditions
CI / Run script/clang-tidy for ESP32 Arduino 3/4 (push) Blocked by required conditions
CI / Run script/clang-tidy for ESP32 Arduino 4/4 (push) Blocked by required conditions
CI / Test components batch (${{ matrix.components }}) (push) Blocked by required conditions
CI / pre-commit.ci lite (push) Blocked by required conditions
CI / Build target branch for memory impact (push) Blocked by required conditions
CI / Build PR branch for memory impact (push) Blocked by required conditions
CI / Comment memory impact (push) Blocked by required conditions
CI / CI Status (push) Blocked by required conditions
[logger] Fix unit test and benchmark Logger constructor calls (#15085)
2026-03-23 09:50:58 +13:00

43 lines
1.3 KiB
C++

#include <benchmark/benchmark.h>
#include "esphome/components/logger/logger.h"
/*
This special main.cpp provides the entry point for Google Benchmark.
It replaces the default ESPHome main with a benchmark runner.
*/
// Auto generated code by esphome
// ========== AUTO GENERATED INCLUDE BLOCK BEGIN ===========
// ========== AUTO GENERATED INCLUDE BLOCK END ===========
void original_setup() {
// Code-generated App initialization (pre_setup, area/device registration, etc.)
// ========== AUTO GENERATED CODE BEGIN ===========
// =========== AUTO GENERATED CODE END ============
}
void setup() {
// Run auto-generated initialization (App.pre_setup, area/device registration,
// looping_components_.init, etc.) so benchmarks that use App work correctly.
original_setup();
// Log functions call global_logger->log_vprintf_() without a null check,
// so we must set up a Logger before any test that triggers logging.
static esphome::logger::Logger test_logger(0, 64);
test_logger.set_log_level(ESPHOME_LOG_LEVEL);
test_logger.pre_setup();
int argc = 1;
char arg0[] = "benchmark";
char *argv[] = {arg0, nullptr};
::benchmark::Initialize(&argc, argv);
::benchmark::RunSpecifiedBenchmarks();
::benchmark::Shutdown();
exit(0);
}
void loop() {}