Skip to content

Commit 863ab4d

Browse files
committed
url: add benchmark for param append for URL and URLSearchParams
1 parent a05675c commit 863ab4d

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed
+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
'use strict';
2+
const common = require('../common.js');
3+
4+
const bench = common.createBenchmark(main, {
5+
type: ['URL', 'URLSearchParams'],
6+
n: [1e4],
7+
});
8+
9+
function main({ type, n }) {
10+
const params = type === 'URL' ?
11+
new URL('https://nodejs.org').searchParams :
12+
new URLSearchParams();
13+
14+
bench.start();
15+
for (let i = 0; i < n; i++) {
16+
params.append('hello', 'world');
17+
}
18+
bench.end(n);
19+
}

0 commit comments

Comments
 (0)