Skip to content

Commit

Permalink
mention benchmark results in readme.
Browse files Browse the repository at this point in the history
  • Loading branch information
fiatjaf committed Dec 22, 2023
1 parent 5d795c2 commit 397931f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
17 changes: 16 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,22 @@ const relay = AbstractRelay.connect('wss://relayable.org', { verifyEvent })
const pool = new AbstractSimplePool({ verifyEvent })
```

This may be faster than the pure-JS [noble libraries](https://paulmillr.com/noble/) used by default and in `nostr-tools/pure`.
This may be faster than the pure-JS [noble libraries](https://paulmillr.com/noble/) used by default and in `nostr-tools/pure`. Benchmarks:

```
benchmark time (avg) (min … max) p75 p99 p995
------------------------------------------------- -----------------------------
• relay read message and verify event (many events)
------------------------------------------------- -----------------------------
wasm 34.94 ms/iter (34.61 ms … 35.73 ms) 35.07 ms 35.73 ms 35.73 ms
pure js 239.7 ms/iter (235.41 ms … 243.69 ms) 240.51 ms 243.69 ms 243.69 ms
trusted 402.71 µs/iter (344.57 µs … 2.98 ms) 407.39 µs 745.62 µs 812.59 µs
summary for relay read message and verify event
wasm
86.77x slower than trusted
6.86x faster than pure js
```

### Using from the browser (if you don't want to use a bundler)

Expand Down
2 changes: 1 addition & 1 deletion benchmark.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ const runWith = (relay: AbstractRelay) => async () => {
})
}

group('relay read message and verify event', () => {
group('relay read message and verify event (many events)', () => {
baseline('wasm', runWith(wasmRelay))
bench('pure js', runWith(pureRelay))
bench('trusted', runWith(trustedRelay))
Expand Down

0 comments on commit 397931f

Please sign in to comment.