minht11 / local-music-pwa

Lightweight on device music player PWA.
https://snaeplayer.com/
MIT License
154 stars 20 forks source link

Optimize checking if track already exists. #9

Closed minht11 closed 3 years ago

minht11 commented 3 years ago

Previously each file handle was compared to one another using only isSameEntry, that's very expensive. Now we check if file names are also matching before using isSameEntry, because if file is renamed it will automatically won't match, so it's safe to do that. Other optimization is removing already found tracks from existing tracks search pool.

Original diff, on my machine, with 462 tracks, took 11000ms, with this PR it takes about 300ms. 36x times improvement. Still this could be optimized even more.

Partially fixes https://github.com/minht11/local-music-pwa/issues/8

netlify[bot] commented 3 years ago

✔️ Deploy Preview for heuristic-ptolemy-02be89 ready!

🔨 Explore the source changes: 73273dbbe868fe493adde867abea935aaa3abdf4

🔍 Inspect the deploy log: https://app.netlify.com/sites/heuristic-ptolemy-02be89/deploys/611d95a51958030007a7437c

😎 Browse the preview: https://deploy-preview-9--heuristic-ptolemy-02be89.netlify.app/

lennyanders commented 3 years ago

Wow, this is way faster compared to what I tested. It somehow only took 2 seconds.