chore: add benchmark and tests for GetManagedObjects (#150)

This commit is contained in:
J. Nick Koston
2022-11-04 17:20:47 +01:00
committed by GitHub
parent 61d2869d96
commit 2d566224d3
3 changed files with 49 additions and 0 deletions

View File

@@ -0,0 +1,25 @@
import io
import timeit
from dbus_fast._private.unmarshaller import Unmarshaller
# cythonize -X language_level=3 -a -i src/dbus_fast/_private/unmarshaller.py
with open("tests/data/get_managed_objects.hex") as fp:
msg = fp.read()
stream = io.BytesIO(bytes.fromhex(msg))
unmarshaller = Unmarshaller(stream)
def unmarhsall_bluez_get_managed_objects_message():
stream.seek(0)
unmarshaller.reset()
unmarshaller.unmarshall()
count = 10000
time = timeit.Timer(unmarhsall_bluez_get_managed_objects_message).timeit(count)
print(f"Unmarshalling {count} bluetooth GetManagedObjects messages took {time} seconds")