Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
test: fix long-running buffer benchmarks
  • Loading branch information
apapirovski committed Apr 18, 2018
commit 88708b17d5d5847c9f29d69d051c429b0ede410c
6 changes: 3 additions & 3 deletions benchmark/buffers/buffer-base64-decode-wrapped.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
const common = require('../common.js');

const bench = common.createBenchmark(main, {
charsPerLine: [76],
linesCount: [8 << 16],
n: [32],
});

function main({ n }) {
const charsPerLine = 76;
const linesCount = 8 << 16;
function main({ charsPerLine, linesCount, n }) {
const bytesCount = charsPerLine * linesCount / 4 * 3;

const line = `${'abcd'.repeat(charsPerLine / 4)}\n`;
Expand Down
5 changes: 3 additions & 2 deletions benchmark/buffers/buffer-base64-decode.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ const common = require('../common.js');

const bench = common.createBenchmark(main, {
n: [32],
size: [8 << 20]
});

function main({ n }) {
const s = 'abcd'.repeat(8 << 20);
function main({ n, size }) {
const s = 'abcd'.repeat(size);
// eslint-disable-next-line node-core/no-unescaped-regexp-dot
s.match(/./); // Flatten string.
assert.strictEqual(s.length % 4, 0);
Expand Down
8 changes: 4 additions & 4 deletions benchmark/buffers/buffer-indexof.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ const bench = common.createBenchmark(main, {
search: searchStrings,
encoding: ['undefined', 'utf8', 'ucs2', 'binary'],
type: ['buffer', 'string'],
iter: [100000]
n: [100000]
});

function main({ iter, search, encoding, type }) {
function main({ n, search, encoding, type }) {
var aliceBuffer = fs.readFileSync(
path.resolve(__dirname, '../fixtures/alice.html')
);
Expand All @@ -46,8 +46,8 @@ function main({ iter, search, encoding, type }) {
}

bench.start();
for (var i = 0; i < iter; i++) {
for (var i = 0; i < n; i++) {
aliceBuffer.indexOf(search, 0, encoding);
}
bench.end(iter);
bench.end(n);
}
2 changes: 2 additions & 0 deletions test/sequential/test-benchmark-buffer.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@ runBenchmark('buffers',
'args=1',
'buffer=fast',
'byteLength=1',
'charsPerLine=6',
'encoding=utf8',
'endian=BE',
'len=2',
'linesCount=1',
'method=',
'n=1',
'pieces=1',
Expand Down