From 7279b455811f4806dcb74a08d17b837bc22533c1 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 18 Jul 2018 14:17:54 +0200 Subject: Speed up populate database script --- server/tests/real-world/populate-database.ts | 29 +++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) (limited to 'server/tests') diff --git a/server/tests/real-world/populate-database.ts b/server/tests/real-world/populate-database.ts index f0f82f7f8..d41ac8d36 100644 --- a/server/tests/real-world/populate-database.ts +++ b/server/tests/real-world/populate-database.ts @@ -38,15 +38,26 @@ async function start () { // Forever const fakeTab = Array.from(Array(1000000).keys()) - await Bluebird.map(fakeTab, () => { - return Promise.all([ - uploadCustom(server), - likeCustom(server), - dislikeCustom(server), - createUserCustom(server), - createCustomChannel(server) - ]).catch(err => console.error(err)) - }, { concurrency: 5 }) + const funs = [ + uploadCustom + // uploadCustom, + // uploadCustom, + // uploadCustom, + // likeCustom, + // createUserCustom, + // createCustomChannel + ] + const promises = [] + + for (const fun of funs) { + promises.push( + Bluebird.map(fakeTab, () => { + return fun(server).catch(err => console.error(err)) + }, { concurrency: 3 }) + ) + } + + await Promise.all(promises) } function getRandomInt (min, max) { -- cgit v1.2.3