From 4b7dfe1e7764d8424b1be935c7fea09a102382e8 Mon Sep 17 00:00:00 2001 From: bndw Date: Mon, 16 Feb 2026 10:58:11 -0800 Subject: fix: cleanup bench --- BENCHMARKS.md | 47 ++++++++++++++++++++++++----------------------- 1 file changed, 24 insertions(+), 23 deletions(-) (limited to 'BENCHMARKS.md') diff --git a/BENCHMARKS.md b/BENCHMARKS.md index 14a861c..1a671c1 100644 --- a/BENCHMARKS.md +++ b/BENCHMARKS.md @@ -2,7 +2,7 @@ This directory contains comprehensive benchmarks comparing three popular Go Nostr libraries: -- **NWIO** (`northwest.io/nostr`) - This library +- **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 @@ -25,61 +25,60 @@ This directory contains comprehensive benchmarks comparing three popular Go Nost ## Running Benchmarks -**Important**: The comparison benchmarks require the `benchcmp` build tag to avoid polluting the module dependencies with competitor libraries. +**Important**: The comparison benchmarks are in a separate module (`benchmarks/comparison/`) to avoid polluting the main module dependencies with competitor libraries. ### Quick Start -Run all benchmarks (automatically handles dependencies): +Run all comparison benchmarks: ```bash -./run_benchmarks.sh -``` - -Or manually: -```bash -# First, get the comparison dependencies -go get -tags=benchcmp -t ./... - -# Then run the benchmarks -go test -tags=benchcmp -bench=. -benchmem -benchtime=1s +cd benchmarks/comparison +go test -bench=. -benchmem -benchtime=1s ``` ### Specific Benchmark Groups Event unmarshaling: ```bash -go test -tags=benchcmp -bench=BenchmarkEventUnmarshal -benchmem +cd benchmarks/comparison +go test -bench=BenchmarkEventUnmarshal -benchmem ``` Event signing: ```bash -go test -tags=benchcmp -bench=BenchmarkEventSign -benchmem +cd benchmarks/comparison +go test -bench=BenchmarkEventSign -benchmem ``` Event verification: ```bash -go test -tags=benchcmp -bench=BenchmarkEventVerify -benchmem +cd benchmarks/comparison +go test -bench=BenchmarkEventVerify -benchmem ``` Filter matching: ```bash -go test -tags=benchcmp -bench=BenchmarkFilterMatch -benchmem +cd benchmarks/comparison +go test -bench=BenchmarkFilterMatch -benchmem ``` ### Compare Single Library NWIO only: ```bash -go test -tags=benchcmp -bench='.*_NWIO' -benchmem +cd benchmarks/comparison +go test -bench='.*_NWIO' -benchmem ``` NBD only: ```bash -go test -tags=benchcmp -bench='.*_NBD' -benchmem +cd benchmarks/comparison +go test -bench='.*_NBD' -benchmem ``` Fiat only: ```bash -go test -tags=benchcmp -bench='.*_Fiat' -benchmem +cd benchmarks/comparison +go test -bench='.*_Fiat' -benchmem ``` ## Analyzing Results @@ -91,14 +90,16 @@ Use `benchstat` for statistical analysis: go install golang.org/x/perf/cmd/benchstat@latest # Run benchmarks multiple times and compare -go test -tags=benchcmp -bench=. -benchmem -count=10 > results.txt +cd benchmarks/comparison +go test -bench=. -benchmem -count=10 > results.txt benchstat results.txt ``` Compare two specific libraries: ```bash -go test -tags=benchcmp -bench='.*_NWIO' -benchmem -count=10 > nwio.txt -go test -tags=benchcmp -bench='.*_NBD' -benchmem -count=10 > nbd.txt +cd benchmarks/comparison +go test -bench='.*_NWIO' -benchmem -count=10 > nwio.txt +go test -bench='.*_NBD' -benchmem -count=10 > nbd.txt benchstat nwio.txt nbd.txt ``` -- cgit v1.2.3