1'use strict'; 2const common = require('../common.js'); 3 4const bench = common.createBenchmark(main, { 5 accessMethod: ['get', 'getAll', 'has'], 6 param: ['one', 'two', 'three', 'nonexistent'], 7 n: [2e7], 8}); 9 10const str = 'one=single&two=first&three=first&two=2nd&three=2nd&three=3rd'; 11 12function main({ accessMethod, param, n }) { 13 const params = new URLSearchParams(str); 14 if (!params[accessMethod]) 15 throw new Error(`Unknown method ${accessMethod}`); 16 17 bench.start(); 18 for (let i = 0; i < n; i += 1) 19 params[accessMethod](param); 20 bench.end(n); 21} 22