-
-
Notifications
You must be signed in to change notification settings - Fork 10
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
use pre calculated utf16 table #29
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! I really liked the idea of pre-calculating utf-16 values. I'll merge this after the previous pull request is merged. GJ @Uzlopak
@Uzlopak Can you update the branch and run a benchmark? |
I ran the Benchmarks. Basically a gain of +15 % for multi byte characters. uzlopak@Battlestation:~/workspace/faster-querystring$ node benchmark/bench-cmp-branch.js
Select the branch you want to compare (feature branch):
encodeString-fast
Select the branch you want to compare with (main branch):
main
Checking out "encodeString-fast"
Execute "npm run benchmark"
> fast-querystring@1.0.0 benchmark
> node benchmark/bench.js
encodeString: "" x 301,800,480 ops/sec ±0.39% (193 runs sampled)
encodeString: "123" x 124,991,538 ops/sec ±0.15% (194 runs sampled)
encodeString: "ä" x 149,392,191 ops/sec ±0.16% (194 runs sampled)
encodeString: "𝌆" x 33,263,591 ops/sec ±0.33% (191 runs sampled)
stringify: undefined x 1,252,964,447 ops/sec ±0.12% (195 runs sampled)
stringify: null x 1,256,352,113 ops/sec ±0.07% (194 runs sampled)
stringify: {} x 123,117,277 ops/sec ±0.65% (182 runs sampled)
stringify: { id: true } x 35,804,756 ops/sec ±0.62% (187 runs sampled)
stringify: { id: false } x 37,444,187 ops/sec ±0.22% (194 runs sampled)
stringify: { id: 123 } x 29,385,111 ops/sec ±0.62% (187 runs sampled)
stringify: { id: 1e+22 } x 12,593,301 ops/sec ±0.52% (191 runs sampled)
stringify: { id: 123n } x 19,516,558 ops/sec ±1.19% (186 runs sampled)
stringify: { id: Infinity } x 45,336,574 ops/sec ±0.60% (190 runs sampled)
stringify: { id: ["1", "3"] } x 16,322,006 ops/sec ±0.48% (187 runs sampled)
stringify: { id: "" } x 39,664,504 ops/sec ±0.72% (187 runs sampled)
stringify: { id: "123" } x 28,509,920 ops/sec ±0.47% (190 runs sampled)
stringify: { id: "ä" } x 26,778,841 ops/sec ±0.67% (191 runs sampled)
stringify: { id: "𝌆" } x 17,288,323 ops/sec ±0.63% (186 runs sampled)
stringify: { foo: ["1", "3"], bar: "2" } x 9,261,218 ops/sec ±0.24% (193 runs sampled)
parse: x 159,142,387 ops/sec ±0.16% (194 runs sampled)
parse: id=123 x 16,084,981 ops/sec ±0.66% (188 runs sampled)
parse: id=123&id=123 x 8,123,288 ops/sec ±0.32% (190 runs sampled)
parse: full%20name=Yagiz x 6,064,912 ops/sec ±0.26% (192 runs sampled)
parse: invalid%key=hello x 6,567,817 ops/sec ±0.30% (189 runs sampled)
parse: my+weird+field=q1%212%22%27w%245%267%2Fz8%29%3F x 1,384,351 ops/sec ±0.13% (193 runs sampled)
Checking out "main"
Execute "npm run benchmark"
> fast-querystring@1.0.0 benchmark
> node benchmark/bench.js
encodeString: "" x 292,799,787 ops/sec ±0.43% (184 runs sampled)
encodeString: "123" x 117,099,112 ops/sec ±0.41% (190 runs sampled)
encodeString: "ä" x 78,184,297 ops/sec ±0.23% (192 runs sampled)
encodeString: "𝌆" x 33,798,774 ops/sec ±0.20% (192 runs sampled)
stringify: undefined x 1,267,372,485 ops/sec ±0.10% (193 runs sampled)
stringify: null x 1,266,193,122 ops/sec ±0.12% (195 runs sampled)
stringify: {} x 135,395,111 ops/sec ±0.90% (189 runs sampled)
stringify: { id: true } x 35,467,821 ops/sec ±0.87% (191 runs sampled)
stringify: { id: false } x 36,171,446 ops/sec ±0.34% (192 runs sampled)
stringify: { id: 123 } x 30,249,729 ops/sec ±0.53% (191 runs sampled)
stringify: { id: 1e+22 } x 13,052,192 ops/sec ±0.41% (192 runs sampled)
stringify: { id: 123n } x 20,219,939 ops/sec ±1.17% (194 runs sampled)
stringify: { id: Infinity } x 44,973,263 ops/sec ±0.30% (191 runs sampled)
stringify: { id: ["1", "3"] } x 16,815,705 ops/sec ±0.55% (189 runs sampled)
stringify: { id: "" } x 41,464,595 ops/sec ±0.22% (193 runs sampled)
stringify: { id: "123" } x 29,420,972 ops/sec ±0.47% (190 runs sampled)
stringify: { id: "ä" } x 23,466,180 ops/sec ±0.57% (188 runs sampled)
stringify: { id: "𝌆" } x 16,935,083 ops/sec ±0.56% (186 runs sampled)
stringify: { foo: ["1", "3"], bar: "2" } x 9,004,421 ops/sec ±0.28% (191 runs sampled)
parse: x 159,501,239 ops/sec ±0.13% (191 runs sampled)
parse: id=123 x 14,838,103 ops/sec ±0.43% (187 runs sampled)
parse: id=123&id=123 x 7,829,497 ops/sec ±0.59% (187 runs sampled)
parse: full%20name=Yagiz x 5,691,966 ops/sec ±0.20% (192 runs sampled)
parse: invalid%key=hello x 6,565,851 ops/sec ±0.27% (190 runs sampled)
parse: my+weird+field=q1%212%22%27w%245%267%2Fz8%29%3F x 1,370,609 ops/sec ±0.13% (194 runs sampled)
encodeString: "" .+3.07%
encodeString: "123" .+6.74%
encodeString: "ä" +91.08%
encodeString: "𝌆" .-1.58%
stringify: undefined .-1.14%
stringify: null .-0.78%
stringify: {} .-9.07%
stringify: { id: true } .+0.95%
stringify: { id: false } .+3.52%
stringify: { id: 123 } .-2.86%
stringify: { id: 1e+22 } .-3.52%
stringify: { id: 123n } .-3.48%
stringify: { id: Infinity } .+0.81%
stringify: { id: ["1", "3"] } .-2.94%
stringify: { id: "" } .-4.34%
stringify: { id: "123" } ..-3.1%
stringify: { id: "ä" } +14.12%
stringify: { id: "𝌆" } .+2.09%
stringify: { foo: ["1", "3"], bar: "2" } .+2.85%
parse: .-0.22%
parse: id=123 ..+8.4%
parse: id=123&id=123 .+3.75%
parse: full%20name=Yagiz .+6.55%
parse: invalid%key=hello .+0.03%
parse: my+weird+field=q1%212%22%27w%245%267%2Fz8%29%3F....+1%
Back to encodeString-fast df5744c |
* add benchmarks * adapt changes for fast-querystring * update package-lock.yaml * use precalculated utf16 table
Morning @anonrig, could you cut a new release of this package please? Would love to take advantage of these performance improvements! |
I just released a new version. Thanks for the patience @Fdawgs https://github.com/anonrig/fast-querystring/releases/tag/1.1.0 |
If #25 gets merged, we could compare it. It seems to double the encodeString performance for utf16 characters.