Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf(router): improve performance of router #3526

Merged
merged 2 commits into from
Oct 26, 2024

Conversation

EdamAme-x
Copy link
Contributor

@EdamAme-x EdamAme-x commented Oct 18, 2024

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
  • Run tests
  • bun run format:fix && bun run lint:fix to format the code
  • Add TSDoc/JSDoc to document the code

Copy link

codecov bot commented Oct 18, 2024

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 ⚠️
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     

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

@usualoma
Copy link
Member

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 👍

Copy link
Member

@yusukebe yusukebe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@yusukebe
Copy link
Member

@EdamAme-x

Thanks! I'll merge this now.

@yusukebe yusukebe merged commit 10a5e65 into honojs:main Oct 26, 2024
16 checks passed
TinsFox pushed a commit to TinsFox/hono that referenced this pull request Oct 28, 2024
* perf(router):  improve performance of router

* coverage
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.

3 participants