benchmark: (zlib) use destructuring
PR-URL: https://github.com/nodejs/node/pull/18250 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
parent
49f5e08188
commit
5dfb93d2fa
@ -10,14 +10,13 @@ const bench = common.createBenchmark(main, {
|
|||||||
n: [5e5]
|
n: [5e5]
|
||||||
});
|
});
|
||||||
|
|
||||||
function main(conf) {
|
function main({ n, type, options }) {
|
||||||
const n = +conf.n;
|
const fn = zlib[`create${type}`];
|
||||||
const fn = zlib[`create${conf.type}`];
|
|
||||||
if (typeof fn !== 'function')
|
if (typeof fn !== 'function')
|
||||||
throw new Error('Invalid zlib type');
|
throw new Error('Invalid zlib type');
|
||||||
var i = 0;
|
var i = 0;
|
||||||
|
|
||||||
if (conf.options === 'true') {
|
if (options === 'true') {
|
||||||
const opts = {};
|
const opts = {};
|
||||||
bench.start();
|
bench.start();
|
||||||
for (; i < n; ++i)
|
for (; i < n; ++i)
|
||||||
|
@ -8,10 +8,8 @@ const bench = common.createBenchmark(main, {
|
|||||||
n: [4e5]
|
n: [4e5]
|
||||||
});
|
});
|
||||||
|
|
||||||
function main(conf) {
|
function main({ n, method, inputLen }) {
|
||||||
const n = +conf.n;
|
const chunk = Buffer.alloc(inputLen, 'a');
|
||||||
const method = conf.method;
|
|
||||||
const chunk = Buffer.alloc(+conf.inputLen, 'a');
|
|
||||||
|
|
||||||
var i = 0;
|
var i = 0;
|
||||||
switch (method) {
|
switch (method) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user