2016-02-20 02:03:16 +01:00
|
|
|
'use strict';
|
2017-09-14 03:48:53 +02:00
|
|
|
const common = require('../common.js');
|
|
|
|
const querystring = require('querystring');
|
|
|
|
const inputs = require('../fixtures/url-inputs.js').searchParams;
|
2016-11-24 20:43:35 +01:00
|
|
|
|
2017-09-14 03:48:53 +02:00
|
|
|
const bench = common.createBenchmark(main, {
|
2017-01-18 10:19:03 +01:00
|
|
|
type: Object.keys(inputs),
|
2015-02-15 05:26:50 +01:00
|
|
|
n: [1e6],
|
|
|
|
});
|
|
|
|
|
2017-12-30 03:56:18 +01:00
|
|
|
function main({ type, n }) {
|
2017-09-14 03:48:53 +02:00
|
|
|
const input = inputs[type];
|
2017-02-08 09:23:03 +01:00
|
|
|
var i;
|
2017-03-01 12:45:05 +01:00
|
|
|
// Execute the function a "sufficient" number of times before the timed
|
|
|
|
// loop to ensure the function is optimized just once.
|
2017-02-08 09:23:03 +01:00
|
|
|
if (type === 'multicharsep') {
|
|
|
|
for (i = 0; i < n; i += 1)
|
|
|
|
querystring.parse(input, '&&&&&&&&&&');
|
2016-01-31 19:54:18 +01:00
|
|
|
|
|
|
|
bench.start();
|
2016-02-28 06:56:18 +01:00
|
|
|
for (i = 0; i < n; i += 1)
|
2017-02-08 09:23:03 +01:00
|
|
|
querystring.parse(input, '&&&&&&&&&&');
|
2016-01-31 19:54:18 +01:00
|
|
|
bench.end(n);
|
|
|
|
} else {
|
2017-02-08 09:23:03 +01:00
|
|
|
for (i = 0; i < n; i += 1)
|
|
|
|
querystring.parse(input);
|
|
|
|
|
2016-01-31 19:54:18 +01:00
|
|
|
bench.start();
|
2016-02-28 06:56:18 +01:00
|
|
|
for (i = 0; i < n; i += 1)
|
2017-02-08 09:23:03 +01:00
|
|
|
querystring.parse(input);
|
2016-01-31 19:54:18 +01:00
|
|
|
bench.end(n);
|
|
|
|
}
|
2015-02-15 05:26:50 +01:00
|
|
|
}
|