0
0
mirror of https://github.com/nodejs/node.git synced 2024-11-24 12:10:08 +01:00
nodejs/benchmark/url/url-searchparams-append.js
Matt Cowley 925a464cb8
url: remove #context from URLSearchParams
PR-URL: https://github.com/nodejs/node/pull/51520
Fixes: https://github.com/nodejs/node/issues/51518
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz.nizipli@sentry.io>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
2024-01-24 14:36:36 +00:00

20 lines
399 B
JavaScript

'use strict';
const common = require('../common.js');
const bench = common.createBenchmark(main, {
type: ['URL', 'URLSearchParams'],
n: [1e3, 1e6],
});
function main({ type, n }) {
const params = type === 'URL' ?
new URL('https://nodejs.org').searchParams :
new URLSearchParams();
bench.start();
for (let i = 0; i < n; i++) {
params.append('test', i);
}
bench.end(n);
}