Skip to content

Commit

Permalink
fixup! Update parallel benchmarks (Promise + Compose)
Browse files Browse the repository at this point in the history
  • Loading branch information
lundibundi committed Apr 17, 2019
1 parent 4a2f71d commit a128d74
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 24 deletions.
12 changes: 6 additions & 6 deletions tests/load/parallel.compose.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,22 @@ const metasync = require('../..');
const testCompose = done => {
let i = 0;
const p1 = (context, callback) => {
setImmediate(() => callback(null, ++i * 2));
queueMicrotask(() => callback(null, ++i * 2));
};
const p2 = (context, callback) => {
setImmediate(() => callback(null, ++i * 3));
queueMicrotask(() => callback(null, ++i * 3));
};
const p3 = (context, callback) => {
setImmediate(() => callback(null, ++i * 5));
queueMicrotask(() => callback(null, ++i * 5));
};
const p4 = (context, callback) => {
setImmediate(() => callback(null, 'key ' + ++i));
queueMicrotask(() => callback(null, 'key ' + ++i));
};
const p5 = (context, callback) => {
setImmediate(() => callback(null, ++i === 5));
queueMicrotask(() => callback(null, ++i === 5));
};
const p6 = (context, callback) => {
setImmediate(() => callback(null, 'key' + ++i * 2));
queueMicrotask(() => callback(null, 'key' + ++i * 2));
};

const f1 = metasync([[p1, p2, p3, p4, p5, p6]]);
Expand Down
12 changes: 6 additions & 6 deletions tests/load/parallel.promise.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,22 @@ const benchmark = require('./benchmark.js');
const PromiseAll = done => {
let i = 0;
const p1 = new Promise(resolve => {
setImmediate(() => resolve(++i * 2));
resolve(++i * 2);
});
const p2 = new Promise(resolve => {
setImmediate(() => resolve(++i * 3));
resolve(++i * 3);
});
const p3 = new Promise(resolve => {
setImmediate(() => resolve(++i * 5));
resolve(++i * 5);
});
const p4 = new Promise(resolve => {
setImmediate(() => resolve('key ' + ++i));
resolve('key ' + ++i);
});
const p5 = new Promise(resolve => {
setImmediate(() => resolve(++i === 5));
resolve(++i === 5);
});
const p6 = new Promise(resolve => {
setImmediate(() => resolve('key' + ++i * 2));
resolve('key' + ++i * 2);
});

Promise.all([p1, p2, p3, p4, p5, p6]).then(done.bind(null, null));
Expand Down
12 changes: 6 additions & 6 deletions tests/load/sequential.compose.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,22 @@ const metasync = require('../..');
const composeSequential = done => {
let i = 0;
const p1 = (context, callback) => {
setImmediate(() => callback(null, ++i * 2));
queueMicrotask(() => callback(null, ++i * 2));
};
const p2 = (context, callback) => {
setImmediate(() => callback(null, ++i * 3));
queueMicrotask(() => callback(null, ++i * 3));
};
const p3 = (context, callback) => {
setImmediate(() => callback(null, ++i * 5));
queueMicrotask(() => callback(null, ++i * 5));
};
const p4 = (context, callback) => {
setImmediate(() => callback(null, 'key ' + ++i));
queueMicrotask(() => callback(null, 'key ' + ++i));
};
const p5 = (context, callback) => {
setImmediate(() => callback(null, ++i === 5));
queueMicrotask(() => callback(null, ++i === 5));
};
const p6 = (context, callback) => {
setImmediate(() => callback(null, 'key' + ++i * 2));
queueMicrotask(() => callback(null, 'key' + ++i * 2));
};

const f1 = metasync([p1, p2, p3, p4, p5, p6]);
Expand Down
12 changes: 6 additions & 6 deletions tests/load/sequential.promise.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,22 @@ const benchmark = require('./benchmark.js');
const PromiseThen = done => {
let i = 0;
const p1 = new Promise(resolve => {
setImmediate(() => resolve({ p1: ++i * 2 }));
resolve(++i * 2);
});
const p2 = new Promise(resolve => {
setImmediate(() => resolve({ p2: ++i * 3 }));
resolve(++i * 3);
});
const p3 = new Promise(resolve => {
setImmediate(() => resolve({ p3: ++i * 5 }));
resolve(++i * 5);
});
const p4 = new Promise(resolve => {
setImmediate(() => resolve({ p4: 'key ' + ++i }));
resolve('key ' + ++i);
});
const p5 = new Promise(resolve => {
setImmediate(() => resolve({ p5: ++i === 5 }));
resolve(++i === 5);
});
const p6 = new Promise(resolve => {
setImmediate(() => resolve({ p6: 'key' + ++i * 2 }));
resolve('key' + ++i * 2);
});
Promise.resolve()
.then(p1)
Expand Down

0 comments on commit a128d74

Please sign in to comment.