Speed up validate_entity_id (#32137)

* Speed up validate_entity_id

* Add some more invalid entity IDs

* Adjust regular expression

* Extend and sort test cases

* Update regular expression, more cases, faster

* Adjust tests, allow start with number, disallow double underscore

Co-authored-by: Franck Nijhof <frenck@frenck.nl>
This commit is contained in:
Paulus SchoutsenandFranck Nijhof authored and GitHub committed 2020-02-24 08:35:02 -08:00
1 parent 15b4975681
commit 07fa844c43
3 files changed
+46 -2

No files matched your search

@@ -185,3 +185,12 @@ def _logbook_filtering(hass, last_changed, last_updated):
list(logbook.humanify(None, yield_events(event)))
return timer() - start
@benchmark
async def valid_entity_id(hass):
"""Run valid entity ID a million times."""
start = timer()
for _ in range(10 ** 6):
core.valid_entity_id("light.kitchen")
return timer() - start