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(compose): check if it is a instance only once #3585

Merged
merged 3 commits into from
Oct 30, 2024

Conversation

EdamAme-x
Copy link
Contributor

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 30, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 94.72%. Comparing base (3164326) to head (014a81f).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3585   +/-   ##
=======================================
  Coverage   94.72%   94.72%           
=======================================
  Files         158      158           
  Lines        9553     9554    +1     
  Branches     2815     2818    +3     
=======================================
+ Hits         9049     9050    +1     
  Misses        504      504           

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

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

Nice.

I've tried to benchmark for instanceof with this script:

import { bench, group, run } from 'mitata'
import { Context } from '../../src/context'

const c = new Context(new Request('http://localhost'))

bench('noop', async () => {})

group(() => {
  bench('instaceof', async () => {
    c instanceof Context
  })
  bench('noop', async () => {})
})

run()

There is no difference in Bun, but there is a slight difference on Node.js:

-------------------------------------- -------------------------------
instaceof                54.87 ns/iter  54.20 ns █▅
                 (51.39 ns  92.19 ns)  81.03 ns ██▃▂▂▄▂▁▁▁▁▁▁▁▂▂▁▁▁▁▁
noop                     47.66 ns/iter  48.45 ns  
                 (42.72 ns  90.24 ns)  73.71 ns █▃█▅▄▃▃▃▁▁▁▁▁▂▁▂▁▁▁▁▁

Interesting. Let's merge this. Thanks!

@yusukebe yusukebe merged commit efd3d04 into honojs:main Oct 30, 2024
16 checks passed
TinsFox pushed a commit to TinsFox/hono that referenced this pull request Nov 11, 2024
* perf(compose): check if it is a instance only once

* chore: fix syntax

* chore: sort if condition
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