hono icon indicating copy to clipboard operation
hono copied to clipboard

perf(router): improve performance of router

Open EdamAme-x opened this issue 1 year ago • 1 comments

router performance improvements

Explicitly cached lengths, adjusted the order of evaluation of logical expressions, (without regexp router, for readability) and removed debugging properties to speed up and use other unique values. (trie-router)

The author should do the following, if applicable

  • [ ] Add tests
  • [x] Run tests
  • [x] bun run format:fix && bun run lint:fix to format the code
  • [ ] Add TSDoc/JSDoc to document the code

EdamAme-x avatar Oct 18 '24 06:10 EdamAme-x

Codecov Report

Attention: Patch coverage is 95.23810% with 5 lines in your changes missing coverage. Please review.

Project coverage is 94.31%. Comparing base (90833d2) to head (1c681a9). Report is 9 commits behind head on main.

Files with missing lines Patch % Lines
src/router/linear-router/router.ts 94.31% 5 Missing :warning:
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3526      +/-   ##
==========================================
+ Coverage   94.29%   94.31%   +0.01%     
==========================================
  Files         157      157              
  Lines        9488     9492       +4     
  Branches     2763     2779      +16     
==========================================
+ Hits         8947     8952       +5     
+ Misses        541      540       -1     

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov[bot] avatar Oct 18 '24 06:10 codecov[bot]

Hi @EdamAme-x, Thank you!

The performance difference between "for-of" and "for loop" is currently quite small (depending on the runtime), so I don't think it needs to be actively rewritten.

However, looking at the benchmarks for loops, it seems that "for loop" is still the fastest, so the changes in this pull request are reasonable 👍

usualoma avatar Oct 25 '24 23:10 usualoma

@EdamAme-x

Thanks! I'll merge this now.

yusukebe avatar Oct 26 '24 02:10 yusukebe