Skip to content

Commit b01ec9c

Browse files
committed
docs: add querystringify to benchmarks
1 parent 4ed772e commit b01ec9c

File tree

5 files changed

+46
-27
lines changed

5 files changed

+46
-27
lines changed

README.md

Lines changed: 27 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -45,36 +45,38 @@ console.log(qs.stringify({ foo: ['bar', 'baz'] }))
4545
```
4646
> node benchmark/parse.mjs
4747
48-
╔═════════════════════════════════════════╤═════════╤═══════════════════╤═══════════╤══════════════════════════╗
49-
║ Slower tests │ Samples │ Result │ Tolerance │ Difference with previous ║
50-
╟─────────────────────────────────────────┼─────────┼───────────────────┼───────────┼──────────────────────────╢
51-
║ qs │ 10000 │ 295583.95 op/sec │ ± 1.44 % │ ║
52-
║ query-string │ 10000 │ 314370.91 op/sec │ ± 1.07 % │ + 6.36 % ║
53-
║ URLSearchParams-with-Object.fromEntries │ 10000 │ 808356.40 op/sec │ ± 2.45 % │ + 157.13 % ║
54-
║ URLSearchParams-with-construct │ 10000 │ 1135683.90 op/sec │ ± 3.18 % │ + 40.49 % ║
55-
║ node:querystring │ 10000 │ 1275958.09 op/sec │ ± 3.88 % │ + 12.35 % ║
56-
╟─────────────────────────────────────────┼─────────┼───────────────────┼───────────┼──────────────────────────╢
57-
║ Fastest test │ Samples │ Result │ Tolerance │ Difference with previous ║
58-
╟─────────────────────────────────────────┼─────────┼───────────────────┼───────────┼──────────────────────────╢
59-
║ fast-querystring │ 10000 │ 1492040.49 op/sec │ ± 2.77 % │ + 16.93 % ║
60-
╚═════════════════════════════════════════╧═════════╧═══════════════════╧═══════════╧══════════════════════════╝
48+
╔═════════════════════════════════════════╤═════════╤═══════════════════╤═══════════╗
49+
║ Slower tests │ Samples │ Result │ Tolerance ║
50+
╟─────────────────────────────────────────┼─────────┼───────────────────┼───────────╢
51+
║ qs │ 10000 │ 319951.57 op/sec │ ± 1.07 % ║
52+
║ query-string │ 10000 │ 333653.03 op/sec │ ± 1.22 % ║
53+
║ querystringify │ 10000 │ 431400.52 op/sec │ ± 1.72 % ║
54+
║ URLSearchParams-with-Object.fromEntries │ 10000 │ 884654.19 op/sec │ ± 1.50 % ║
55+
║ URLSearchParams-with-construct │ 10000 │ 1184144.96 op/sec │ ± 3.33 % ║
56+
║ node:querystring │ 2500 │ 1413741.68 op/sec │ ± 0.90 % ║
57+
╟─────────────────────────────────────────┼─────────┼───────────────────┼───────────╢
58+
║ Fastest test │ Samples │ Result │ Tolerance ║
59+
╟─────────────────────────────────────────┼─────────┼───────────────────┼───────────╢
60+
║ fast-querystring │ 10000 │ 1503424.80 op/sec │ ± 3.25 % ║
61+
╚═════════════════════════════════════════╧═════════╧═══════════════════╧═══════════╝
6162
```
6263

6364
- Stringify a query-string
6465

6566
```
6667
> node benchmark/stringify.mjs
6768
68-
╔══════════════════╤═════════╤═══════════════════╤═══════════╤══════════════════════════╗
69-
║ Slower tests │ Samples │ Result │ Tolerance │ Difference with previous ║
70-
╟──────────────────┼─────────┼───────────────────┼───────────┼──────────────────────────╢
71-
║ query-string │ 10000 │ 295574.51 op/sec │ ± 1.18 % │ ║
72-
║ qs │ 10000 │ 349191.83 op/sec │ ± 1.42 % │ + 18.14 % ║
73-
║ URLSearchParams │ 1000 │ 605856.45 op/sec │ ± 0.77 % │ + 73.50 % ║
74-
║ node:querystring │ 10000 │ 1829015.91 op/sec │ ± 5.07 % │ + 201.89 % ║
75-
╟──────────────────┼─────────┼───────────────────┼───────────┼──────────────────────────╢
76-
║ Fastest test │ Samples │ Result │ Tolerance │ Difference with previous ║
77-
╟──────────────────┼─────────┼───────────────────┼───────────┼──────────────────────────╢
78-
║ fast-querystring │ 10000 │ 1976753.77 op/sec │ ± 3.43 % │ + 8.08 % ║
79-
╚══════════════════╧═════════╧═══════════════════╧═══════════╧══════════════════════════╝
69+
╔══════════════════╤═════════╤═══════════════════╤═══════════╗
70+
║ Slower tests │ Samples │ Result │ Tolerance ║
71+
╟──────────────────┼─────────┼───────────────────┼───────────╢
72+
║ query-string │ 10000 │ 294312.93 op/sec │ ± 1.31 % ║
73+
║ qs │ 10000 │ 355420.44 op/sec │ ± 1.26 % ║
74+
║ URLSearchParams │ 10000 │ 594915.18 op/sec │ ± 1.47 % ║
75+
║ querystringify │ 10000 │ 785004.65 op/sec │ ± 2.09 % ║
76+
║ node:querystring │ 1500 │ 1864502.85 op/sec │ ± 0.85 % ║
77+
╟──────────────────┼─────────┼───────────────────┼───────────╢
78+
║ Fastest test │ Samples │ Result │ Tolerance ║
79+
╟──────────────────┼─────────┼───────────────────┼───────────╢
80+
║ fast-querystring │ 10000 │ 1893015.11 op/sec │ ± 4.26 % ║
81+
╚══════════════════╧═════════╧═══════════════════╧═══════════╝
8082
```

benchmark/parse.mjs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import qs from "qs";
33
import fastQueryString from "../lib/index.js";
44
import native from "node:querystring";
55
import queryString from "query-string";
6+
import querystringify from "querystringify";
67

78
await benchmark(
89
{
@@ -48,6 +49,11 @@ await benchmark(
4849
}
4950
return data;
5051
},
52+
querystringify() {
53+
return querystringify.parse(
54+
"frappucino=muffin&goat=scone&pond=moose&foo=bar&foo=baz",
55+
);
56+
},
5157
},
52-
{ warmup: true, print: { compare: true, compareMode: "previous" } },
58+
{ warmup: true },
5359
);

benchmark/stringify.mjs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import qs from "qs";
33
import fastQueryString from "../lib/index.js";
44
import native from "node:querystring";
55
import queryString from "query-string";
6+
import querystringify from "querystringify";
67

78
const value = {
89
frappucino: "muffin",
@@ -32,6 +33,9 @@ await benchmark(
3233
const urlParams = new URLSearchParams(value);
3334
return urlParams.toString();
3435
},
36+
querystringify() {
37+
return querystringify.stringify(value);
38+
},
3539
},
36-
{ warmup: true, print: { compare: true, compareMode: "previous" } },
40+
{ warmup: true },
3741
);

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
"cronometro": "^1.1.2",
2929
"qs": "^6.11.0",
3030
"query-string": "^7.1.1",
31+
"querystringify": "^2.2.0",
3132
"rome": "0.9.0-next",
3233
"vitest": "^0.23.1"
3334
},

pnpm-lock.yaml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)