mirror of
https://github.com/esphome/esphome.git
synced 2025-10-22 11:43:51 +01:00
relo
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
"""Memory usage analyzer for ESPHome compiled binaries."""
|
"""Memory usage analyzer for ESPHome compiled binaries."""
|
||||||
|
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
|
from functools import cache
|
||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
@@ -13,6 +14,7 @@ _LOGGER = logging.getLogger(__name__)
|
|||||||
|
|
||||||
|
|
||||||
# Get the list of actual ESPHome components by scanning the components directory
|
# Get the list of actual ESPHome components by scanning the components directory
|
||||||
|
@cache
|
||||||
def get_esphome_components():
|
def get_esphome_components():
|
||||||
"""Get set of actual ESPHome components from the components directory."""
|
"""Get set of actual ESPHome components from the components directory."""
|
||||||
components = set()
|
components = set()
|
||||||
@@ -34,10 +36,6 @@ def get_esphome_components():
|
|||||||
return components
|
return components
|
||||||
|
|
||||||
|
|
||||||
# Cache the component list
|
|
||||||
ESPHOME_COMPONENTS = get_esphome_components()
|
|
||||||
|
|
||||||
|
|
||||||
class MemorySection:
|
class MemorySection:
|
||||||
"""Represents a memory section with its symbols."""
|
"""Represents a memory section with its symbols."""
|
||||||
|
|
||||||
@@ -285,7 +283,7 @@ class MemoryAnalyzer:
|
|||||||
if "esphome::" in demangled:
|
if "esphome::" in demangled:
|
||||||
# Check for special component classes that include component name in the class
|
# Check for special component classes that include component name in the class
|
||||||
# For example: esphome::ESPHomeOTAComponent -> ota component
|
# For example: esphome::ESPHomeOTAComponent -> ota component
|
||||||
for component_name in ESPHOME_COMPONENTS:
|
for component_name in get_esphome_components():
|
||||||
# Check various naming patterns
|
# Check various naming patterns
|
||||||
component_upper = component_name.upper()
|
component_upper = component_name.upper()
|
||||||
component_camel = component_name.replace("_", "").title()
|
component_camel = component_name.replace("_", "").title()
|
||||||
@@ -307,7 +305,7 @@ class MemoryAnalyzer:
|
|||||||
component_name = component_name.rstrip("_")
|
component_name = component_name.rstrip("_")
|
||||||
|
|
||||||
# Check if this is an actual component in the components directory
|
# Check if this is an actual component in the components directory
|
||||||
if component_name in ESPHOME_COMPONENTS:
|
if component_name in get_esphome_components():
|
||||||
return f"[esphome]{component_name}"
|
return f"[esphome]{component_name}"
|
||||||
# Check if this is a known external component from the config
|
# Check if this is a known external component from the config
|
||||||
if component_name in self.external_components:
|
if component_name in self.external_components:
|
||||||
|
Reference in New Issue
Block a user