Skip to content

Commit

Permalink
url: add benchmark for param append for URL and URLSearchParams
Browse files Browse the repository at this point in the history
  • Loading branch information
MattIPv4 committed Jan 19, 2024
1 parent a05675c commit 863ab4d
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions benchmark/url/url-searchparams-append.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
'use strict';
const common = require('../common.js');

const bench = common.createBenchmark(main, {
type: ['URL', 'URLSearchParams'],
n: [1e4],
});

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('hello', 'world');
}
bench.end(n);
}

0 comments on commit 863ab4d

Please sign in to comment.