adjust benchmarks to be done in a more realistic scenario.

This commit is contained in:
fiatjaf
2023-12-22 11:11:04 -03:00
parent f719d99a11
commit ddf1064da9
2 changed files with 7 additions and 7 deletions

View File

@@ -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))

View File

@@ -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