Refactor integration startup time tracking to reduce overhead (#110136)
* Refactor integration startup time tracking to reduce overhead - Use monotonic time for watching integration startup time as it avoids incorrect values if time moves backwards because of ntp during startup and reduces many time conversions since we want durations in seconds and not local time - Use loop scheduling instead of a task - Moves all the dispatcher logic into the new _WatchPendingSetups * websocket as well * tweaks * simplify logic * preserve logic * preserve logic * lint * adjust
This commit is contained in:
parent
9bc130c131
commit
def6c5c21c
5 changed files with 79 additions and 59 deletions
|
@ -2,7 +2,6 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from collections.abc import Callable
|
||||
import datetime as dt
|
||||
from functools import lru_cache, partial
|
||||
import json
|
||||
import logging
|
||||
|
@ -540,13 +539,12 @@ def handle_integration_setup_info(
|
|||
hass: HomeAssistant, connection: ActiveConnection, msg: dict[str, Any]
|
||||
) -> None:
|
||||
"""Handle integrations command."""
|
||||
setup_time: dict[str, float] = hass.data[DATA_SETUP_TIME]
|
||||
connection.send_result(
|
||||
msg["id"],
|
||||
[
|
||||
{"domain": integration, "seconds": timedelta.total_seconds()}
|
||||
for integration, timedelta in cast(
|
||||
dict[str, dt.timedelta], hass.data[DATA_SETUP_TIME]
|
||||
).items()
|
||||
{"domain": integration, "seconds": seconds}
|
||||
for integration, seconds in setup_time.items()
|
||||
],
|
||||
)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue