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
Prev Previous commit
Next Next commit
buffer: Change n to len and added + to ensure it is a number
  • Loading branch information
troy0820 authored and Trott committed Dec 23, 2016
commit 4eb18d608028067ebada7d21cd5c6b994e056dac
4 changes: 2 additions & 2 deletions benchmark/buffers/buffer-base64-decode.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ const assert = require('assert');
const common = require('../common.js');

const bench = common.createBenchmark(main, {
n: [32],
len: [32],
});

function main(conf) {
const n = conf.n;
const n = +conf.len;
const s = 'abcd'.repeat(8 << 20);
s.match(/./); // Flatten string.
assert.strictEqual(s.length % 4, 0);
Expand Down
12 changes: 6 additions & 6 deletions benchmark/buffers/buffer-base64-encode.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ var common = require('../common.js');

const bench = common.createBenchmark(main, {
N: [64 * 1024 * 1024],
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I meant this parameter should be called len. n should stay the same.

n: [32]
len: [32]
});

function main(conf) {
var n = conf.n;
var N = conf.N;
var b = Buffer.allocUnsafe(N);
var s = '';
var i;
const n = +conf.len;
const N = +conf.N;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be const len = +conf.len;

const b = Buffer.allocUnsafe(N);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be const b = Buffer.allocUnsafe(len);

let s = '';
let i;
for (i = 0; i < 256; ++i) s += String.fromCharCode(i);
for (i = 0; i < N; i += 256) b.write(s, i, 256, 'ascii');
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

N here should be len

bench.start();
Expand Down