From 1e07964d8154f47caee368557869b99a7b3ac75c Mon Sep 17 00:00:00 2001 From: Matt Aitken Date: Tue, 14 Nov 2023 15:46:34 +0000 Subject: [PATCH] The parallel perf test is now driven by numbers --- perf/README.md | 19 +++++++++++++++++++ perf/src/index.ts | 12 +++++++----- 2 files changed, 26 insertions(+), 5 deletions(-) create mode 100644 perf/README.md diff --git a/perf/README.md b/perf/README.md new file mode 100644 index 000000000..02025ec53 --- /dev/null +++ b/perf/README.md @@ -0,0 +1,19 @@ +# Performance tester + +You can use this to test the performance locally. + +## Setup + +```bash +pnpm run server +``` + +```bash +pnpm run dev:trigger +``` + +## Run + +```bash +pnpm run start +``` diff --git a/perf/src/index.ts b/perf/src/index.ts index 6d9e6cd2a..cd1a01af8 100644 --- a/perf/src/index.ts +++ b/perf/src/index.ts @@ -56,11 +56,14 @@ async function main() { // } } +const batches = 30; +const concurrentEvents = 5; + async function mainParallel() { console.log("Preparing perf tests..."); // wait for 10 seconds - await new Promise((resolve) => setTimeout(resolve, 10000)); + await new Promise((resolve) => setTimeout(resolve, 5000)); console.log("Starting perf tests in 1 second..."); @@ -68,10 +71,9 @@ async function mainParallel() { await new Promise((resolve) => setTimeout(resolve, 1000)); // Send 5 events per second for 30 seconds (1 event == 10 runs) - for (let i = 0; i < 30; i++) { - console.log("Sending 5 event..."); - - await Promise.all([sendEvent(), sendEvent(), sendEvent(), sendEvent(), sendEvent()]); + for (let i = 0; i < batches; i++) { + console.log(`Sending ${concurrentEvents} events... batch ${i + 1}/${batches}`); + await Promise.all(new Array(concurrentEvents).fill(0).map(sendEvent)); await new Promise((resolve) => setTimeout(resolve, 250)); }