`new URL` is faster
gurgunday opened this issue · 6 comments
Prerequisites
- I have written a descriptive issue title
- I have searched existing issues to ensure the issue has not already been raised
Issue
Since Ada, it seems like new URL
's parsing is significantly faster
Maybe we can deprecate this package? The alternative would be to only keep url serialization since URL
doesn't have an alternative, but I don't know how much it's used
What do you think?
ast-uri: parse domain x 1,199,118 ops/sec ±0.49% (98 runs sampled)
urijs: parse domain x 448,563 ops/sec ±0.10% (99 runs sampled)
WHATWG URL: parse domain x 2,581,665 ops/sec ±0.16% (97 runs sampled)
fast-uri: parse IPv4 x 1,785,608 ops/sec ±1.27% (95 runs sampled)
urijs: parse IPv4 x 370,294 ops/sec ±2.00% (97 runs sampled)
fast-uri: parse IPv6 x 832,663 ops/sec ±0.94% (98 runs sampled)
urijs: parse IPv6 x 280,835 ops/sec ±0.39% (100 runs sampled)
fast-uri: parse URN x 2,234,727 ops/sec ±0.62% (93 runs sampled)
urijs: parse URN x 1,118,988 ops/sec ±2.55% (94 runs sampled)
WHATWG URL: parse URN x 3,097,084 ops/sec ±0.15% (97 runs sampled)
fast-uri: parse URN uuid x 1,487,851 ops/sec ±0.09% (95 runs sampled)
urijs: parse URN uuid x 816,766 ops/sec ±0.09% (99 runs sampled)
fast-uri: serialize uri x 1,109,413 ops/sec ±0.39% (97 runs sampled)
urijs: serialize uri x 380,730 ops/sec ±0.36% (97 runs sampled)
fast-uri: serialize IPv6 x 365,499 ops/sec ±0.10% (100 runs sampled)
The main use of this package is for ajv. For reference: ajv-validator/ajv#1862
It might worth giving a shot at ajv creating a uriresolver using new URL
on recent node versions.
I don't think we should deprecate it yet because ada
is shipped on only recent node versions am i right?
I see, didn't know that AJV used this package 🙏
I agree that we can do polyfills
I don't think we should deprecate it yet because ada is shipped on only recent node versions am i right?
ada
is exist on all the supported version of node
already.
It the version that do not have ada
is EoL.
It came with v18.17.0 , there's still 16 to support. However we can create the polyfill for AJV but with the slow ramp-up of updates in ajv usage i think fast-uri
will still be used for a while. Might be worth updating the benchmarks and readme. I don't think all uses cases the lib supports are covered by new URL
This module exists because urijs
was absurdly slow and the main bottleneck in Ajv startup. I'm not 100% sure that the algorithm used by fast-uri and WHATWG URL are identical, and JSON Schema definitely needs a URI.
🫡