Skip to content

Commit

Permalink
benchmark: remove buffer benchmarks redundancy
Browse files Browse the repository at this point in the history
PR-URL: #45735
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Yagiz Nizipli <[email protected]>
Reviewed-By: Daeyeon Jeong <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Ruben Bridgewater <[email protected]>
Reviewed-By: Rafael Gonzaga <[email protected]>
  • Loading branch information
mscdex authored and juanarbol committed Mar 5, 2023
1 parent 6468f30 commit d0b9be2
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
6 changes: 6 additions & 0 deletions benchmark/buffers/buffer-copy.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 }) {
Expand Down
7 changes: 6 additions & 1 deletion benchmark/buffers/buffer-indexof.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 }) {
Expand Down
7 changes: 6 additions & 1 deletion benchmark/buffers/buffer-tostring.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 }) {
Expand Down

0 comments on commit d0b9be2

Please sign in to comment.