From ddf1064da9220ebb829b598914aba75ab182df86 Mon Sep 17 00:00:00 2001 From: fiatjaf Date: Fri, 22 Dec 2023 11:11:04 -0300 Subject: [PATCH] adjust benchmarks to be done in a more realistic scenario. --- benchmark.ts | 8 ++++---- justfile | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/benchmark.ts b/benchmark.ts index 4b645e0..b359ea6 100644 --- a/benchmark.ts +++ b/benchmark.ts @@ -8,16 +8,16 @@ import { Relay as PureRelay } from './relay.ts' import { alwaysTrue } from './helpers.ts' // benchmarking relay reads with verifyEvent -const EVENTS = 100 +const EVENTS = 200 let messages: string[] = [] let baseContent = '' -for (let i = 0; i < EVENTS / 100; i++) { +for (let i = 0; i < EVENTS; i++) { baseContent += 'a' } const secretKey = generateSecretKey() for (let i = 0; i < EVENTS; i++) { const tags = [] - for (let t = 0; t < i / 100; t++) { + for (let t = 0; t < i; t++) { tags.push(['t', 'nada']) } const event = { created_at: Math.round(Date.now()) / 1000, kind: 1, content: baseContent.slice(0, EVENTS - i), tags } @@ -51,7 +51,7 @@ const runWith = (relay: AbstractRelay) => async () => { }) } -group('relay read message and verify event (many events)', () => { +group(`relay read ${EVENTS} messages and verify its events`, () => { baseline('wasm', runWith(wasmRelay)) bench('pure js', runWith(pureRelay)) bench('trusted', runWith(trustedRelay)) diff --git a/justfile b/justfile index deca36e..ec6c851 100644 --- a/justfile +++ b/justfile @@ -26,7 +26,7 @@ lint: benchmark: bun build --target=node --outfile=bench.js benchmark.ts - timeout 25s deno run --allow-read bench.js || true - timeout 25s node bench.js || true - timeout 25s bun run benchmark.ts || true + timeout 60s deno run --allow-read bench.js || true + timeout 60s node bench.js || true + timeout 60s bun run benchmark.ts || true rm bench.js