Skip to content

Commit ab566e1

Browse files
author
Tony Crisci
authored
Merge pull request #126 from bdraco/unmarshall_performance
Improve unmarshall performance
2 parents 230a5d8 + c26ba7e commit ab566e1

File tree

9 files changed

+454
-347
lines changed

9 files changed

+454
-347
lines changed

bench/unmarshall.py

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import io
2+
import timeit
3+
4+
from dbus_next._private.unmarshaller import Unmarshaller
5+
6+
bluez_rssi_message = (
7+
"6c04010134000000e25389019500000001016f00250000002f6f72672f626c75657a2f686369302f6465"
8+
"765f30385f33415f46325f31455f32425f3631000000020173001f0000006f72672e667265656465736b"
9+
"746f702e444275732e50726f7065727469657300030173001100000050726f706572746965734368616e"
10+
"67656400000000000000080167000873617b73767d617300000007017300040000003a312e3400000000"
11+
"110000006f72672e626c75657a2e446576696365310000000e0000000000000004000000525353490001"
12+
"6e00a7ff000000000000"
13+
)
14+
15+
16+
def unmarhsall_bluez_rssi_message():
17+
Unmarshaller(io.BytesIO(bytes.fromhex(bluez_rssi_message))).unmarshall()
18+
19+
20+
count = 1000000
21+
time = timeit.Timer(unmarhsall_bluez_rssi_message).timeit(count)
22+
print(f"Unmarshalling {count} bluetooth rssi messages took {time} seconds")

dbus_next/_private/constants.py

+3
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,6 @@ class HeaderField(Enum):
1616
SENDER = 7
1717
SIGNATURE = 8
1818
UNIX_FDS = 9
19+
20+
21+
HEADER_NAME_MAP = {field.value: field.name for field in HeaderField}

0 commit comments

Comments
 (0)