mirror of
https://github.com/nbd-wtf/nostr-tools.git
synced 2025-12-08 16:28:49 +00:00
adjust benchmarks to be done in a more realistic scenario.
This commit is contained in:
@@ -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))
|
||||
|
||||
6
justfile
6
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
|
||||
|
||||
Reference in New Issue
Block a user