The parallel perf test is now driven by numbers

This commit is contained in:
Matt Aitken
2023-11-14 15:46:34 +00:00
parent f406e59c45
commit 1e07964d81
2 changed files with 26 additions and 5 deletions
+19
View File
@@ -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
```
+7 -5
View File
@@ -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));
}