Prefilter more logbook events in sql (#36958)

* Prefilter more logbook events in sql

Prefilter sensor events in _keep_event before humanify

Cache static attribute lookup

Reduces logbook execution time by ~35%

* fix mocking in benchmark

* Update tests for logbook users
This commit is contained in:
J. Nick Koston authored and GitHub committed 2020-06-21 10:50:58 -07:00
1 parent 29f128eaad
commit 59e43ab6e4
7 files changed
+275 -108

No files matched your search

+2
View File
@@ -473,6 +473,7 @@ async def test_config(hass):
async def test_logbook_humanify_script_started_event(hass):
"""Test humanifying script started event."""
await async_setup_component(hass, DOMAIN, {})
entity_attr_cache = logbook.EntityAttributeCache(hass)
event1, event2 = list(
logbook.humanify(
@@ -487,6 +488,7 @@ async def test_logbook_humanify_script_started_event(hass):
{ATTR_ENTITY_ID: "script.bye", ATTR_NAME: "Bye Script"},
),
],
entity_attr_cache,
)
)