File: unmarshall_getmanagedobjects.py

package info (click to toggle)
dbus-fast 3.1.2-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,804 kB
  • sloc: python: 9,997; xml: 39; makefile: 29; sh: 5
file content (24 lines) | stat: -rw-r--r-- 605 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
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.unmarshall()


count = 10000
time = timeit.Timer(unmarhsall_bluez_get_managed_objects_message).timeit(count)
print(f"Unmarshalling {count} bluetooth GetManagedObjects messages took {time} seconds")