perf: optimization of request instantiation#3107
Conversation
tsctx
commented
Apr 13, 2024
- Reuse fetch optimization logic in core.
- Avoid lowercasing.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3107 +/- ##
==========================================
- Coverage 94.17% 94.16% -0.02%
==========================================
Files 90 90
Lines 24320 24320
==========================================
- Hits 22904 22901 -3
- Misses 1416 1419 +3 ☔ View full report in Codecov by Sentry. |
KhafraDev
left a comment
There was a problem hiding this comment.
Is there a reason to combine method validation and normalization into a single method? This instantly breaks the second we need one and not the other.
The reason for wanting to normalize and verify at the same time is that the case used in the verification can be reused.
Yes, it is. The function was not changed, but a new one was created. |
metcoder95
left a comment
There was a problem hiding this comment.
Can you share the bench results?
Detailsimport Request from "../../lib/core/request.js";
import DecoratorHandler from "../../lib/handler/decorator-handler.js";
import { bench, group, run } from 'mitata'
const handler = new DecoratorHandler({})
bench('new Request()', () => {
return new Request('https://localhost', { path: "/", method: "get", body: null }, handler);
})
await run()
|
|
Thank you for the benchmark. Can you add it to the benchmark folder please? |
KhafraDev
left a comment
There was a problem hiding this comment.
validate and normalize are two different things, please split them as the spec states to do