From d0b9be21eb581f9a7e045b95e5b2e9b3fd80a8a2 Mon Sep 17 00:00:00 2001 From: Brian White Date: Sun, 4 Dec 2022 14:12:38 -0500 Subject: [PATCH] benchmark: remove buffer benchmarks redundancy PR-URL: https://github.com/nodejs/node/pull/45735 Reviewed-By: Matteo Collina Reviewed-By: Yagiz Nizipli Reviewed-By: Daeyeon Jeong Reviewed-By: Luigi Pinca Reviewed-By: Ruben Bridgewater Reviewed-By: Rafael Gonzaga --- benchmark/buffers/buffer-copy.js | 6 ++++++ benchmark/buffers/buffer-indexof.js | 7 ++++++- benchmark/buffers/buffer-tostring.js | 7 ++++++- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/benchmark/buffers/buffer-copy.js b/benchmark/buffers/buffer-copy.js index 164f31420766d5..054f72ef41cf7f 100644 --- a/benchmark/buffers/buffer-copy.js +++ b/benchmark/buffers/buffer-copy.js @@ -5,6 +5,12 @@ const bench = common.createBenchmark(main, { bytes: [0, 8, 128, 32 * 1024], partial: ['true', 'false'], n: [6e6] +}, { + combinationFilter: (p) => { + return (p.partial === 'false' && p.bytes === 0) || + (p.partial !== 'false' && p.bytes !== 0); + }, + test: { partial: 'false', bytes: 0 }, }); function main({ n, bytes, partial }) { diff --git a/benchmark/buffers/buffer-indexof.js b/benchmark/buffers/buffer-indexof.js index 4c0993a1ef0ef9..1b02a8bb7d9d38 100644 --- a/benchmark/buffers/buffer-indexof.js +++ b/benchmark/buffers/buffer-indexof.js @@ -19,9 +19,14 @@ const searchStrings = [ const bench = common.createBenchmark(main, { search: searchStrings, - encoding: ['utf8', 'ucs2'], + encoding: ['undefined', 'utf8', 'ucs2'], type: ['buffer', 'string'], n: [5e4] +}, { + combinationFilter: (p) => { + return (p.type === 'buffer' && p.encoding === 'undefined') || + (p.type !== 'buffer' && p.encoding !== 'undefined'); + }, }); function main({ n, search, encoding, type }) { diff --git a/benchmark/buffers/buffer-tostring.js b/benchmark/buffers/buffer-tostring.js index 98d6ab3fa08311..ac4e7f6c86e010 100644 --- a/benchmark/buffers/buffer-tostring.js +++ b/benchmark/buffers/buffer-tostring.js @@ -3,10 +3,15 @@ const common = require('../common.js'); const bench = common.createBenchmark(main, { - encoding: ['utf8', 'ascii', 'latin1', 'hex', 'UCS-2'], + encoding: ['', 'utf8', 'ascii', 'latin1', 'hex', 'UCS-2'], args: [0, 1, 3], len: [1, 64, 1024], n: [1e6] +}, { + combinationFilter: (p) => { + return (p.args === 0 && p.encoding === '') || + (p.args !== 0 && p.encoding !== ''); + }, }); function main({ encoding, args, len, n }) {