Skip to content

Commit

Permalink
benchmark: (string_decoder) use destructuring
Browse files Browse the repository at this point in the history
PR-URL: #18250
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
BridgeAR authored and evanlucas committed Jan 30, 2018
1 parent 5b0e3b9 commit 97e8820
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 12 deletions.
5 changes: 1 addition & 4 deletions benchmark/string_decoder/string-decoder-create.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@ const bench = common.createBenchmark(main, {
n: [25e6]
});

function main(conf) {
const encoding = conf.encoding;
const n = conf.n | 0;

function main({ encoding, n }) {
bench.start();
for (var i = 0; i < n; ++i) {
const sd = new StringDecoder(encoding);
Expand Down
11 changes: 3 additions & 8 deletions benchmark/string_decoder/string-decoder.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,16 @@ const StringDecoder = require('string_decoder').StringDecoder;

const bench = common.createBenchmark(main, {
encoding: ['ascii', 'utf8', 'base64-utf8', 'base64-ascii', 'utf16le'],
inlen: [32, 128, 1024, 4096],
chunk: [16, 64, 256, 1024],
inLen: [32, 128, 1024, 4096],
chunkLen: [16, 64, 256, 1024],
n: [25e5]
});

const UTF8_ALPHA = 'Blåbærsyltetøy';
const ASC_ALPHA = 'Blueberry jam';
const UTF16_BUF = Buffer.from('Blåbærsyltetøy', 'utf16le');

function main(conf) {
const encoding = conf.encoding;
const inLen = conf.inlen | 0;
const chunkLen = conf.chunk | 0;
const n = conf.n | 0;

function main({ encoding, inLen, chunkLen, n }) {
var alpha;
var buf;
const chunks = [];
Expand Down

0 comments on commit 97e8820

Please sign in to comment.