mirror of
https://github.com/nodejs/node.git
synced 2024-11-28 06:28:40 +01:00
20 lines
399 B
JavaScript
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);
|
||
|
}
|