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 2020-06-21 12:50:58 -05:00 committed by GitHub
parent 29f128eaad
commit 59e43ab6e4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 275 additions and 108 deletions

View file

@ -17,6 +17,7 @@ async def test_humanify_homekit_changed_event(hass, hk_driver):
"""Test humanifying HomeKit changed event."""
with patch("homeassistant.components.homekit.HomeKit"):
assert await async_setup_component(hass, "homekit", {"homekit": {}})
entity_attr_cache = logbook.EntityAttributeCache(hass)
event1, event2 = list(
logbook.humanify(
@ -40,6 +41,7 @@ async def test_humanify_homekit_changed_event(hass, hk_driver):
},
),
],
entity_attr_cache,
)
)