Skip to content

Commit

Permalink
aioble/multitests: Use multitest.output_metric for perf results.
Browse files Browse the repository at this point in the history
The perf multitests now "pass" when run.

Signed-off-by: Damien George <[email protected]>
  • Loading branch information
dpgeorge committed May 25, 2024
1 parent a7a84ca commit f4efda7
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 2 deletions.
6 changes: 5 additions & 1 deletion micropython/bluetooth/aioble/multitests/perf_gatt_notify.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ async def instance0_task():
20_000, adv_data=b"\x02\x01\x06\x04\xffMPY", timeout_ms=TIMEOUT_MS
)

print("connect")

client_characteristic = await discover_server(connection)

# Give the central enough time to discover chars.
Expand All @@ -61,7 +63,7 @@ async def instance0_task():

ticks_end = time.ticks_ms()
ticks_total = time.ticks_diff(ticks_end, ticks_start)
print(
multitest.output_metric(
"Acknowledged {} notifications in {} ms. {} ms/notification.".format(
_NUM_NOTIFICATIONS, ticks_total, ticks_total // _NUM_NOTIFICATIONS
)
Expand All @@ -87,6 +89,8 @@ async def instance1_task():
device = aioble.Device(*BDADDR)
connection = await device.connect(timeout_ms=TIMEOUT_MS)

print("connect")

client_characteristic = await discover_server(connection)

for i in range(_NUM_NOTIFICATIONS):
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
--- instance0 ---
connect
--- instance1 ---
connect
6 changes: 5 additions & 1 deletion micropython/bluetooth/aioble/multitests/perf_l2cap.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ async def instance0_task():
20_000, adv_data=b"\x02\x01\x06\x04\xffMPY", timeout_ms=TIMEOUT_MS
)

print("connect")

channel = await connection.l2cap_accept(_L2CAP_PSM, _L2CAP_MTU, timeout_ms=TIMEOUT_MS)

random.seed(_RANDOM_SEED)
Expand Down Expand Up @@ -66,6 +68,8 @@ async def instance1_task():
device = aioble.Device(*BDADDR)
connection = await device.connect(timeout_ms=TIMEOUT_MS)

print("connect")

await asyncio.sleep_ms(500)

channel = await connection.l2cap_connect(_L2CAP_PSM, _L2CAP_MTU, timeout_ms=TIMEOUT_MS)
Expand All @@ -90,7 +94,7 @@ async def instance1_task():
ticks_end = time.ticks_ms()
total_ticks = time.ticks_diff(ticks_end, ticks_first_byte)

print(
multitest.output_metric(
"Received {}/{} bytes in {} ms. {} B/s".format(
recv_bytes, recv_correct, total_ticks, recv_bytes * 1000 // total_ticks
)
Expand Down
4 changes: 4 additions & 0 deletions micropython/bluetooth/aioble/multitests/perf_l2cap.py.exp
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
--- instance0 ---
connect
--- instance1 ---
connect

0 comments on commit f4efda7

Please sign in to comment.