| 1 |
|
| 2 |
"""pytest-benchmark mirror of tests/benchmarks/test_parse_gap_uuid_lists. |
| 3 |
|
| 4 |
Kept in sync with the codspeed suite so CI step summaries surface the same |
| 5 |
multi-entry UUID list scenarios that the safe_end hoist (PR #253) targets. |
| 6 |
""" |
| 7 |
|
| 8 |
from bluetooth_data_tools.gap import _uncached_parse_advertisement_bytes |
| 9 |
|
| 10 |
_FLAGS = b"\x02\x01\x06" |
| 11 |
_LOCAL_NAME = b"\x07\tDevice" |
| 12 |
_UUIDS_16 = b"\x0f\x03\x12\x18\x0a\x18\x0d\x18\x0f\x18\x05\x18\x09\x18\x02\x18" |
| 13 |
_UUIDS_32 = b"\x0d\x05\x12\x18\x00\x00\x0a\x18\x00\x00\x0d\x18\x00\x00" |
| 14 |
_UUIDS_128 = b"\x21\x07" + bytes(range(16)) + bytes(range(16, 32)) |
| 15 |
|
| 16 |
ADV_16BIT_LIST = _FLAGS + _UUIDS_16 + _LOCAL_NAME |
| 17 |
ADV_32BIT_LIST = _FLAGS + _UUIDS_32 + _LOCAL_NAME |
| 18 |
ADV_128BIT_LIST = _FLAGS + _UUIDS_128 + _LOCAL_NAME |
| 19 |
ADV_MIXED_LIST = _FLAGS + _UUIDS_16 + _UUIDS_32 + _UUIDS_128 + _LOCAL_NAME |
| 20 |
|
| 21 |
|
| 22 |
def test_parse_advertisement_16bit_uuid_list(benchmark): |
| 23 |
benchmark(lambda: _uncached_parse_advertisement_bytes(ADV_16BIT_LIST)) |
| 24 |
|
| 25 |
|
| 26 |
def test_parse_advertisement_32bit_uuid_list(benchmark): |
| 27 |
benchmark(lambda: _uncached_parse_advertisement_bytes(ADV_32BIT_LIST)) |
| 28 |
|
| 29 |
|
| 30 |
def test_parse_advertisement_128bit_uuid_list(benchmark): |
| 31 |
benchmark(lambda: _uncached_parse_advertisement_bytes(ADV_128BIT_LIST)) |
| 32 |
|
| 33 |
|
| 34 |
def test_parse_advertisement_mixed_uuid_lists(benchmark): |
| 35 |
benchmark(lambda: _uncached_parse_advertisement_bytes(ADV_MIXED_LIST)) |