From 1988984398dac14daf93f11005b647b646bdf00a Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Sat, 22 Mar 2025 15:57:16 -1000 Subject: [PATCH] chore: add benchmark for interfaces added message (#432) --- tests/benchmarks/test_unmarshall.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/tests/benchmarks/test_unmarshall.py b/tests/benchmarks/test_unmarshall.py index bbe596a..1307437 100644 --- a/tests/benchmarks/test_unmarshall.py +++ b/tests/benchmarks/test_unmarshall.py @@ -99,3 +99,31 @@ def test_unmarshall_multiple_bluez_properties_message_socket( sock1.close() sock2.close() + + +def test_unmarshall_bluez_interfaces_added_message(benchmark: BenchmarkFixture) -> None: + bluez_interfaces_added_message = ( + b'l\4\1\1\240\2\0\0\227\272\23\0u\0\0\0\1\1o\0\1\0\0\0/\0\0\0\0\0\0\0\2\1s\0"\0\0\0' + b"org.freedesktop.DBus.ObjectManager\0\0\0\0\0\0\3\1s\0\17\0\0\0InterfacesAdded\0\10" + b"\1g\0\noa{sa{sv}}\0\7\1s\0\4\0\0\0:1.4\0\0\0\0%\0\0\0/org/bluez/hci1/dev_58_2D_34" + b"_60_26_36\0\0\0p\2\0\0#\0\0\0org.freedesktop.DBus.Introspectable\0\0\0\0\0\0\0\0\0" + b"\21\0\0\0org.bluez.Device1\0\0\0\364\1\0\0\0\0\0\0\7\0\0\0Address\0\1s\0\0\21\0\0" + b"\00058:2D:34:60:26:36\0\0\0\v\0\0\0AddressType\0\1s\0\0\6\0\0\0public\0\0\4\0\0\0" + b"Name\0\1s\0\33\0\0\0Qingping Door/Window Sensor\0\0\0\0\0\5\0\0\0Alias\0\1s\0\0\0" + b"\0\33\0\0\0Qingping Door/Window Sensor\0\6\0\0\0Paired\0\1b\0\0\0\0\0\0\0\0\0\0\0" + b"\7\0\0\0Trusted\0\1b\0\0\0\0\0\0\0\0\0\0\7\0\0\0Blocked\0\1b\0\0\0\0\0\0\0\0\0\0\r" + b"\0\0\0LegacyPairing\0\1b\0\0\0\0\0\0\0\0\0\0\0\0\4\0\0\0RSSI\0\1n\0\316\377\0\0\t" + b"\0\0\0Connected\0\1b\0\0\0\0\0\0\0\0\5\0\0\0UUIDs\0\2as\0\0\0\0\0\0\0\0\0\0\0\7\0" + b"\0\0Adapter\0\1o\0\0\17\0\0\0/org/bluez/hci1\0\0\0\0\0\v\0\0\0ServiceData\0\5a{sv}" + b"\0\0@\0\0\0\0\0\0\0$\0\0\0000000fe95-0000-1000-8000-00805f9b34fb\0\2ay\0\0\0\0\f\0" + b"\0\0000X\326\3\0026&`4-X\10\20\0\0\0ServicesResolved\0\1b\0\0\0\0\0\0\0\0\0\37\0\0" + b"\0org.freedesktop.DBus.Properties\0\0\0\0\0" + ) + stream = io.BytesIO(bluez_interfaces_added_message) + + unmarshaller = Unmarshaller(stream) + + @benchmark + def unmarshall(): + stream.seek(0) + unmarshaller.unmarshall()