summaryrefslogtreecommitdiffstats
path: root/BENCHMARKS.md
diff options
context:
space:
mode:
authorbndw <ben@bdw.to>2026-02-16 10:58:11 -0800
committerbndw <ben@bdw.to>2026-02-16 10:58:11 -0800
commit4b7dfe1e7764d8424b1be935c7fea09a102382e8 (patch)
treebd80dc38b0c3d9e4332b9f5df25c17fb4943ea64 /BENCHMARKS.md
parent7a5d5a53e5d6878f38382c4d35f644e088d318d2 (diff)
fix: cleanup bench
Diffstat (limited to 'BENCHMARKS.md')
-rw-r--r--BENCHMARKS.md47
1 files changed, 24 insertions, 23 deletions
diff --git a/BENCHMARKS.md b/BENCHMARKS.md
index 14a861c..1a671c1 100644
--- a/BENCHMARKS.md
+++ b/BENCHMARKS.md
@@ -2,7 +2,7 @@
2 2
3This directory contains comprehensive benchmarks comparing three popular Go Nostr libraries: 3This directory contains comprehensive benchmarks comparing three popular Go Nostr libraries:
4 4
5- **NWIO** (`northwest.io/nostr`) - This library 5- **NWIO** (`code.northwest.io/nostr`) - This library
6- **NBD** (`github.com/nbd-wtf/go-nostr`) - Popular community library 6- **NBD** (`github.com/nbd-wtf/go-nostr`) - Popular community library
7- **Fiat** (`fiatjaf.com/nostr`) - Original implementation by Fiatjaf 7- **Fiat** (`fiatjaf.com/nostr`) - Original implementation by Fiatjaf
8 8
@@ -25,61 +25,60 @@ This directory contains comprehensive benchmarks comparing three popular Go Nost
25 25
26## Running Benchmarks 26## Running Benchmarks
27 27
28**Important**: The comparison benchmarks require the `benchcmp` build tag to avoid polluting the module dependencies with competitor libraries. 28**Important**: The comparison benchmarks are in a separate module (`benchmarks/comparison/`) to avoid polluting the main module dependencies with competitor libraries.
29 29
30### Quick Start 30### Quick Start
31 31
32Run all benchmarks (automatically handles dependencies): 32Run all comparison benchmarks:
33```bash 33```bash
34./run_benchmarks.sh 34cd benchmarks/comparison
35``` 35go test -bench=. -benchmem -benchtime=1s
36
37Or manually:
38```bash
39# First, get the comparison dependencies
40go get -tags=benchcmp -t ./...
41
42# Then run the benchmarks
43go test -tags=benchcmp -bench=. -benchmem -benchtime=1s
44``` 36```
45 37
46### Specific Benchmark Groups 38### Specific Benchmark Groups
47 39
48Event unmarshaling: 40Event unmarshaling:
49```bash 41```bash
50go test -tags=benchcmp -bench=BenchmarkEventUnmarshal -benchmem 42cd benchmarks/comparison
43go test -bench=BenchmarkEventUnmarshal -benchmem
51``` 44```
52 45
53Event signing: 46Event signing:
54```bash 47```bash
55go test -tags=benchcmp -bench=BenchmarkEventSign -benchmem 48cd benchmarks/comparison
49go test -bench=BenchmarkEventSign -benchmem
56``` 50```
57 51
58Event verification: 52Event verification:
59```bash 53```bash
60go test -tags=benchcmp -bench=BenchmarkEventVerify -benchmem 54cd benchmarks/comparison
55go test -bench=BenchmarkEventVerify -benchmem
61``` 56```
62 57
63Filter matching: 58Filter matching:
64```bash 59```bash
65go test -tags=benchcmp -bench=BenchmarkFilterMatch -benchmem 60cd benchmarks/comparison
61go test -bench=BenchmarkFilterMatch -benchmem
66``` 62```
67 63
68### Compare Single Library 64### Compare Single Library
69 65
70NWIO only: 66NWIO only:
71```bash 67```bash
72go test -tags=benchcmp -bench='.*_NWIO' -benchmem 68cd benchmarks/comparison
69go test -bench='.*_NWIO' -benchmem
73``` 70```
74 71
75NBD only: 72NBD only:
76```bash 73```bash
77go test -tags=benchcmp -bench='.*_NBD' -benchmem 74cd benchmarks/comparison
75go test -bench='.*_NBD' -benchmem
78``` 76```
79 77
80Fiat only: 78Fiat only:
81```bash 79```bash
82go test -tags=benchcmp -bench='.*_Fiat' -benchmem 80cd benchmarks/comparison
81go test -bench='.*_Fiat' -benchmem
83``` 82```
84 83
85## Analyzing Results 84## Analyzing Results
@@ -91,14 +90,16 @@ Use `benchstat` for statistical analysis:
91go install golang.org/x/perf/cmd/benchstat@latest 90go install golang.org/x/perf/cmd/benchstat@latest
92 91
93# Run benchmarks multiple times and compare 92# Run benchmarks multiple times and compare
94go test -tags=benchcmp -bench=. -benchmem -count=10 > results.txt 93cd benchmarks/comparison
94go test -bench=. -benchmem -count=10 > results.txt
95benchstat results.txt 95benchstat results.txt
96``` 96```
97 97
98Compare two specific libraries: 98Compare two specific libraries:
99```bash 99```bash
100go test -tags=benchcmp -bench='.*_NWIO' -benchmem -count=10 > nwio.txt 100cd benchmarks/comparison
101go test -tags=benchcmp -bench='.*_NBD' -benchmem -count=10 > nbd.txt 101go test -bench='.*_NWIO' -benchmem -count=10 > nwio.txt
102go test -bench='.*_NBD' -benchmem -count=10 > nbd.txt
102benchstat nwio.txt nbd.txt 103benchstat nwio.txt nbd.txt
103``` 104```
104 105