summaryrefslogtreecommitdiffstats
path: root/run_benchmarks.sh
diff options
context:
space:
mode:
authorbndw <ben@bdw.to>2026-02-14 18:56:19 -0800
committerbndw <ben@bdw.to>2026-02-14 18:56:19 -0800
commit7a5d5a53e5d6878f38382c4d35f644e088d318d2 (patch)
tree5f8ba0bee800a5998ec4167c47e4adc6602243e1 /run_benchmarks.sh
parent7fba76d7e4e63e0c29da81d6be43330743af1aaf (diff)
feat: add library comparison benchmarks with build tag isolation
Add comprehensive benchmarks comparing NWIO against nbd-wtf/go-nostr and fiatjaf.com/nostr across event operations, signing, verification, and filtering. Use build tag 'benchcmp' to prevent competitor libraries from polluting module dependencies - they're only downloaded when explicitly running comparison tests.
Diffstat (limited to 'run_benchmarks.sh')
-rwxr-xr-xrun_benchmarks.sh35
1 files changed, 35 insertions, 0 deletions
diff --git a/run_benchmarks.sh b/run_benchmarks.sh
new file mode 100755
index 0000000..87dfd17
--- /dev/null
+++ b/run_benchmarks.sh
@@ -0,0 +1,35 @@
1#!/bin/bash
2set -e
3
4# Colors for output
5GREEN='\033[0;32m'
6BLUE='\033[0;34m'
7YELLOW='\033[1;33m'
8NC='\033[0m' # No Color
9
10echo -e "${BLUE}Running Nostr Library Benchmarks${NC}"
11echo -e "${BLUE}Comparing: NWIO vs NBD-WTF vs Fiatjaf${NC}"
12echo ""
13
14# First, install comparison dependencies if needed
15echo -e "${YELLOW}Ensuring comparison dependencies are available...${NC}"
16go get -tags=benchcmp -t ./...
17echo ""
18
19# Run all benchmarks with the benchcmp build tag
20echo -e "${GREEN}Running all benchmarks...${NC}"
21go test -tags=benchcmp -bench=. -benchmem -benchtime=1s -run=^$ | tee benchmark_results.txt
22
23echo ""
24echo -e "${GREEN}Results saved to benchmark_results.txt${NC}"
25echo ""
26echo -e "${BLUE}To run specific benchmark groups:${NC}"
27echo " go test -tags=benchcmp -bench=BenchmarkEventUnmarshal -benchmem"
28echo " go test -tags=benchcmp -bench=BenchmarkEventSign -benchmem"
29echo " go test -tags=benchcmp -bench=BenchmarkEventVerify -benchmem"
30echo " go test -tags=benchcmp -bench=BenchmarkFilterMatch -benchmem"
31echo ""
32echo -e "${BLUE}To compare specific libraries:${NC}"
33echo " go test -tags=benchcmp -bench='.*_NWIO' -benchmem"
34echo " go test -tags=benchcmp -bench='.*_NBD' -benchmem"
35echo " go test -tags=benchcmp -bench='.*_Fiat' -benchmem"