Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
aa6fdf1
benchmark: (arrays) use destructuring
BridgeAR Dec 30, 2017
52cfd34
benchmark: (assert) use destructuring
BridgeAR Dec 30, 2017
a47b478
benchmark: (url) use destructuring
BridgeAR Dec 30, 2017
d6d4b6b
benchmark: (zlib) use destructuring
BridgeAR Dec 30, 2017
e032fee
benchmark: (util/v8/vm) use destructuring
BridgeAR Dec 30, 2017
67d158c
benchmark: (tls) use destructuring
BridgeAR Dec 30, 2017
69e7083
benchmark: (timers) use destructuring
BridgeAR Dec 30, 2017
c84762f
benchmark: (streams) use destructuring
BridgeAR Dec 30, 2017
e841268
benchmark: (querystring) use destructuring
BridgeAR Dec 30, 2017
ae5a06f
benchmark: (process) use destructuring
BridgeAR Dec 30, 2017
15c3b26
benchmark: (net) use destructuring
BridgeAR Dec 30, 2017
8bfa3af
benchmark: (os) use destructuring
BridgeAR Dec 30, 2017
b4609ab
benchmark: (path) use destructuring
BridgeAR Dec 30, 2017
62976e0
benchmark: (string_decoder) use destructuring
BridgeAR Dec 30, 2017
7e0df93
benchmark: (http2) use destructuring
BridgeAR Dec 30, 2017
c56feec
benchmark: (misc) use destructuring
BridgeAR Dec 30, 2017
a0b8fa3
benchmark: (http) use destructuring
BridgeAR Dec 30, 2017
9473627
benchmark: (fs) use destructuring
BridgeAR Dec 30, 2017
c3adef5
benchmark: (es) use destructuring
BridgeAR Dec 30, 2017
7a7ecad
benchmark: (events) use destructuring
BridgeAR Dec 30, 2017
f90cd1d
benchmark: (buffers) use destructuring
BridgeAR Dec 30, 2017
d746d5a
benchmark: (child_process) use destructuring
BridgeAR Dec 30, 2017
171a010
benchmark: (dgram) use destructuring
BridgeAR Dec 30, 2017
3a99ff9
benchmark: use destructuring
BridgeAR Dec 30, 2017
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
benchmark: (assert) use destructuring
PR-URL: #18250
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
BridgeAR committed Jan 23, 2018
commit 52cfd34c667432e93edd769ddcb300753acc9fa2
6 changes: 2 additions & 4 deletions benchmark/assert/deepequal-buffer.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ const bench = common.createBenchmark(main, {
]
});

function main(conf) {
const n = +conf.n;
const len = +conf.len;
function main({ len, n, method }) {
var i;

const data = Buffer.allocUnsafe(len + 1);
Expand All @@ -26,7 +24,7 @@ function main(conf) {
data.copy(expected);
data.copy(expectedWrong);

switch (conf.method) {
switch (method) {
case '':
// Empty string falls through to next line as default, mostly for tests.
case 'deepEqual':
Expand Down
7 changes: 2 additions & 5 deletions benchmark/assert/deepequal-map.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,11 @@ function benchmark(method, n, values, values2) {
bench.end(n);
}

function main(conf) {
const n = +conf.n;
const len = +conf.len;

function main({ n, len, method }) {
const array = Array(len).fill(1);
var values, values2;

switch (conf.method) {
switch (method) {
case '':
// Empty string falls through to next line as default, mostly for tests.
case 'deepEqual_primitiveOnly':
Expand Down
9 changes: 4 additions & 5 deletions benchmark/assert/deepequal-object.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,17 @@ function createObj(source, add = '') {
}));
}

function main(conf) {
const size = +conf.size;
// TODO: Fix this "hack"
const n = (+conf.n) / size;
function main({ size, n, method }) {
// TODO: Fix this "hack". `n` should not be manipulated.
n = n / size;
var i;

const source = Array.apply(null, Array(size));
const actual = createObj(source);
const expected = createObj(source);
const expectedWrong = createObj(source, '4');

switch (conf.method) {
switch (method) {
case '':
// Empty string falls through to next line as default, mostly for tests.
case 'deepEqual':
Expand Down
10 changes: 4 additions & 6 deletions benchmark/assert/deepequal-prims-and-objs-big-array-set.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const primValues = {
};

const bench = common.createBenchmark(main, {
prim: Object.keys(primValues),
primitive: Object.keys(primValues),
n: [25],
len: [1e5],
method: [
Expand All @@ -30,10 +30,8 @@ const bench = common.createBenchmark(main, {
]
});

function main(conf) {
const prim = primValues[conf.prim];
const n = +conf.n;
const len = +conf.len;
function main({ n, len, primitive, method }) {
const prim = primValues[primitive];
const actual = [];
const expected = [];
const expectedWrong = [];
Expand All @@ -52,7 +50,7 @@ function main(conf) {
const expectedSet = new Set(expected);
const expectedWrongSet = new Set(expectedWrong);

switch (conf.method) {
switch (method) {
case '':
// Empty string falls through to next line as default, mostly for tests.
case 'deepEqual_Array':
Expand Down
9 changes: 4 additions & 5 deletions benchmark/assert/deepequal-prims-and-objs-big-loop.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const primValues = {
};

const bench = common.createBenchmark(main, {
prim: Object.keys(primValues),
primitive: Object.keys(primValues),
n: [1e6],
method: [
'deepEqual',
Expand All @@ -24,16 +24,15 @@ const bench = common.createBenchmark(main, {
]
});

function main(conf) {
const prim = primValues[conf.prim];
const n = +conf.n;
function main({ n, primitive, method }) {
const prim = primValues[primitive];
const actual = prim;
const expected = prim;
const expectedWrong = 'b';
var i;

// Creates new array to avoid loop invariant code motion
switch (conf.method) {
switch (method) {
case '':
// Empty string falls through to next line as default, mostly for tests.
case 'deepEqual':
Expand Down
7 changes: 2 additions & 5 deletions benchmark/assert/deepequal-set.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,12 @@ function benchmark(method, n, values, values2) {
bench.end(n);
}

function main(conf) {
const n = +conf.n;
const len = +conf.len;

function main({ n, len, method }) {
const array = Array(len).fill(1);

var values, values2;

switch (conf.method) {
switch (method) {
case '':
// Empty string falls through to next line as default, mostly for tests.
case 'deepEqual_primitiveOnly':
Expand Down
8 changes: 2 additions & 6 deletions benchmark/assert/deepequal-typedarrays.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,16 @@ const bench = common.createBenchmark(main, {
len: [1e6]
});

function main(conf) {
const type = conf.type;
function main({ type, n, len, method }) {
const clazz = global[type];
const n = +conf.n;
const len = +conf.len;

const actual = new clazz(len);
const expected = new clazz(len);
const expectedWrong = Buffer.alloc(len);
const wrongIndex = Math.floor(len / 2);
expectedWrong[wrongIndex] = 123;
var i;

switch (conf.method) {
switch (method) {
case '':
// Empty string falls through to next line as default, mostly for tests.
case 'deepEqual':
Expand Down
7 changes: 3 additions & 4 deletions benchmark/assert/throws.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,14 @@ const bench = common.createBenchmark(main, {
]
});

function main(conf) {
const n = +conf.n;
function main({ n, method }) {
const throws = () => { throw new TypeError('foobar'); };
const doesNotThrow = () => { return 'foobar'; };
const regExp = /foobar/;
const message = 'failure';
var i;

switch (conf.method) {
switch (method) {
case '':
// Empty string falls through to next line as default, mostly for tests.
case 'doesNotThrow':
Expand Down Expand Up @@ -54,6 +53,6 @@ function main(conf) {
bench.end(n);
break;
default:
throw new Error(`Unsupported method ${conf.method}`);
throw new Error(`Unsupported method ${method}`);
}
}