summaryrefslogtreecommitdiffstats
path: root/benchmarks/comparison/README.md
blob: 1b97429391e1b9465c12d1faca6a682cf63bc9f7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# Nostr Library Comparison Benchmarks

This module contains benchmarks comparing `code.northwest.io/nostr` with other popular Go Nostr libraries:

- **NWIO** (`code.northwest.io/nostr`) - This library
- **NBD** (`github.com/nbd-wtf/go-nostr`) - Popular community library
- **Fiat** (`fiatjaf.com/nostr`) - Original implementation by Fiatjaf

## Why a Separate Module?

The comparison libraries are isolated in this separate Go module to keep the main `code.northwest.io/nostr` package clean. Users who import the main package won't have `fiatjaf.com/nostr` or `github.com/nbd-wtf/go-nostr` pulled into their dependency tree.

## Running Benchmarks

From this directory:

```bash
# Run all comparison benchmarks
go test -bench=. -benchmem

# Run specific benchmarks
go test -bench=BenchmarkEventSign -benchmem

# Compare NWIO vs NBD
go test -bench='.*_(NWIO|NBD)' -benchmem
```

From the project root:

```bash
cd benchmarks/comparison
go test -bench=. -benchmem
```

## Benchmark Categories

- **Event Unmarshaling/Marshaling**: JSON parsing and serialization
- **Event Serialization**: Canonical serialization for ID computation
- **Event ID Computation**: Computing event ID hashes
- **Key Generation**: Generating new private keys
- **Event Signing/Verification**: Cryptographic operations
- **Filter Matching**: Simple and complex filter matching

See [../../BENCHMARKS.md](../../BENCHMARKS.md) for detailed documentation.