abandonware / noble

A Node.js BLE (Bluetooth Low Energy) central module : Community maintained
https://libraries.io/npm/@abandonware%2Fnoble
MIT License
538 stars 162 forks source link

Update DiscoverPeripheralUUIDs to Use Object Map for Performance #300

Closed ColeMurray closed 1 year ago

ColeMurray commented 1 year ago

When running a continuous scan, the discoverPeripheralUUIDs continues to grow. Over time, this leads to slow lookup, as the existing implementation is required to perform an O(n) search through an array for each packet received.

To improve performance, we convert the array to an object map, allowing for O(1) lookup. This leads to a 98% performance improvement.

image

codecov-commenter commented 1 year ago

Codecov Report

Merging #300 (bb82fe5) into master (084ef2b) will decrease coverage by 0.07%. The diff coverage is 100.00%.

:mega: This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more

@@            Coverage Diff             @@
##           master     #300      +/-   ##
==========================================
- Coverage   91.86%   91.80%   -0.07%     
==========================================
  Files          24       24              
  Lines        2901     2903       +2     
==========================================
  Hits         2665     2665              
- Misses        236      238       +2     
Impacted Files Coverage Δ
lib/hci-socket/gap.js 87.83% <100.00%> (-1.21%) :arrow_down:
lib/noble.js 98.40% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

ColeMurray commented 1 year ago

@rzr Any additional feedback here?

rzr commented 1 year ago

More reviewers welcome . any testers around ?

Meanwhile you can rebase and squash those 2 commits