Skip to content

test(bench): cover _uint16/_uint32_int_as_uuid and short_address#270

Merged
bdraco merged 1 commit into
Bluetooth-Devices:mainfrom
bluetoothbot:koan/bench-uuid-converters
May 21, 2026
Merged

test(bench): cover _uint16/_uint32_int_as_uuid and short_address#270
bdraco merged 1 commit into
Bluetooth-Devices:mainfrom
bluetoothbot:koan/bench-uuid-converters

Conversation

@bluetoothbot

@bluetoothbot bluetoothbot commented May 21, 2026

Copy link
Copy Markdown
Contributor

What

Direct codspeed + pytest-benchmark coverage for three hot-path helpers in gap.py / utils.py that previously only had indirect coverage via the parse-advertisement benchmarks.

  • _uint16_int_as_uuid — looked up per 16-bit UUID inside the service-UUID list loop and from TYPE_SERVICE_DATA.
  • _uint32_int_as_uuid — same role for 32-bit UUIDs (also TYPE_SERVICE_DATA_32BIT_UUID).
  • short_address — used by human_readable_name and by external callers; benchmarked for both : and - separators (dash always goes through the replace+split path).

Why

The 16/32-bit converters changed call shape in #251 (int-keyed instead of bytes-keyed) and the 128-bit sibling got a fresh benchmark in #267. The remaining two converters and short_address had no direct baseline, so any future change would lack a regression signal.

How

Pattern matches test_mac_to_int.py / test_int_to_bluetooth_address.py: one codspeed file under tests/benchmarks/ and a parallel bench/ mirror without the type annotation (per the convention noted in #258).

Testing

  • pytest tests/benchmarks/test_uint16_int_as_uuid.py tests/benchmarks/test_uint32_int_as_uuid.py tests/benchmarks/test_short_address.py --codspeed — 4 benchmarks, all green.
  • pytest bench/test_uint16_int_as_uuid.py bench/test_uint32_int_as_uuid.py bench/test_short_address.py — 4 benchmarks, all green.
  • ruff check tests/benchmarks/ bench/ — clean.

Test-only; no behaviour change.


Quality Report

Changes: 6 files changed, 44 insertions(+)

Code scan: clean

Tests: failed (FAILED)

Branch hygiene: clean

Generated by Kōan post-mission quality pipeline

Adds direct codspeed + pytest-benchmark coverage for three hot-path
helpers that previously only had indirect coverage via the gap parse
benchmarks:

- _uint16_int_as_uuid (per-16-bit-UUID lookup in service_uuids loop)
- _uint32_int_as_uuid (per-32-bit-UUID lookup, also used by 32-bit
  service data)
- short_address (called from human_readable_name and by external
  callers; dash-input is benchmarked separately to baseline the
  replace+split path)

Test-only; no behaviour change.
@codecov

codecov Bot commented May 21, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (95b0c33) to head (cf38173).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##              main      #270   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            6         6           
  Lines          266       266           
  Branches        42        42           
=========================================
  Hits           266       266           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@codspeed-hq

codspeed-hq Bot commented May 21, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 20 untouched benchmarks
🆕 4 new benchmarks

Performance Changes

Benchmark BASE HEAD Efficiency
🆕 test_short_address_colon N/A 19.6 µs N/A
🆕 test_short_address_dash N/A 20.2 µs N/A
🆕 test_uint16_int_as_uuid_cached N/A 12.1 µs N/A
🆕 test_uint32_int_as_uuid_cached N/A 12 µs N/A

Comparing bluetoothbot:koan/bench-uuid-converters (cf38173) with main (95b0c33)

Open in CodSpeed

@bdraco bdraco marked this pull request as ready for review May 21, 2026 03:09
@bdraco bdraco merged commit f628b11 into Bluetooth-Devices:main May 21, 2026
49 checks passed
@bluetoothbot bluetoothbot deleted the koan/bench-uuid-converters branch May 21, 2026 09:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants