From 4a2f71d121ab184e6b0c23a3508bdb65a0b814f9 Mon Sep 17 00:00:00 2001 From: Denys Otrishko Date: Wed, 5 Dec 2018 22:55:38 +0200 Subject: [PATCH] Update parallel benchmarks (Promise + Compose) * Don't create object every time in Promise resolve * Collect results in an array in Compose bench as it is dome in Promise.all --- tests/load/parallel.compose.js | 2 +- tests/load/parallel.promise.js | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/load/parallel.compose.js b/tests/load/parallel.compose.js index d7644dba..6d8e7a1c 100644 --- a/tests/load/parallel.compose.js +++ b/tests/load/parallel.compose.js @@ -27,7 +27,7 @@ const testCompose = done => { }; const f1 = metasync([[p1, p2, p3, p4, p5, p6]]); - f1(done); + f1([], done); }; benchmark.do(COUNT, [testCompose]); diff --git a/tests/load/parallel.promise.js b/tests/load/parallel.promise.js index d7f3259c..0d8ec77b 100644 --- a/tests/load/parallel.promise.js +++ b/tests/load/parallel.promise.js @@ -7,25 +7,25 @@ const benchmark = require('./benchmark.js'); const PromiseAll = done => { let i = 0; const p1 = new Promise(resolve => { - setImmediate(() => resolve({ p1: ++i * 2 })); + setImmediate(() => resolve(++i * 2)); }); const p2 = new Promise(resolve => { - setImmediate(() => resolve({ p2: ++i * 3 })); + setImmediate(() => resolve(++i * 3)); }); const p3 = new Promise(resolve => { - setImmediate(() => resolve({ p3: ++i * 5 })); + setImmediate(() => resolve(++i * 5)); }); const p4 = new Promise(resolve => { - setImmediate(() => resolve({ p4: 'key ' + ++i })); + setImmediate(() => resolve('key ' + ++i)); }); const p5 = new Promise(resolve => { - setImmediate(() => resolve({ p5: ++i === 5 })); + setImmediate(() => resolve(++i === 5)); }); const p6 = new Promise(resolve => { - setImmediate(() => resolve({ p6: 'key' + ++i * 2 })); + setImmediate(() => resolve('key' + ++i * 2)); }); - Promise.all([p1, p2, p3, p4, p5, p6]).then(res => done(null, res)); + Promise.all([p1, p2, p3, p4, p5, p6]).then(done.bind(null, null)); }; benchmark.do(COUNT, [PromiseAll]);