Skip to content

Commit

Permalink
adjust benchmarks to be done in a more realistic scenario.
Browse files Browse the repository at this point in the history
  • Loading branch information
fiatjaf committed Dec 22, 2023
1 parent f719d99 commit ddf1064
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
8 changes: 4 additions & 4 deletions benchmark.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down Expand Up @@ -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))
Expand Down
6 changes: 3 additions & 3 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit ddf1064

Please sign in to comment.