From 7a5d5a53e5d6878f38382c4d35f644e088d318d2 Mon Sep 17 00:00:00 2001 From: bndw Date: Sat, 14 Feb 2026 18:56:19 -0800 Subject: 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. --- run_benchmarks.sh | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100755 run_benchmarks.sh (limited to 'run_benchmarks.sh') 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 @@ +#!/bin/bash +set -e + +# Colors for output +GREEN='\033[0;32m' +BLUE='\033[0;34m' +YELLOW='\033[1;33m' +NC='\033[0m' # No Color + +echo -e "${BLUE}Running Nostr Library Benchmarks${NC}" +echo -e "${BLUE}Comparing: NWIO vs NBD-WTF vs Fiatjaf${NC}" +echo "" + +# First, install comparison dependencies if needed +echo -e "${YELLOW}Ensuring comparison dependencies are available...${NC}" +go get -tags=benchcmp -t ./... +echo "" + +# Run all benchmarks with the benchcmp build tag +echo -e "${GREEN}Running all benchmarks...${NC}" +go test -tags=benchcmp -bench=. -benchmem -benchtime=1s -run=^$ | tee benchmark_results.txt + +echo "" +echo -e "${GREEN}Results saved to benchmark_results.txt${NC}" +echo "" +echo -e "${BLUE}To run specific benchmark groups:${NC}" +echo " go test -tags=benchcmp -bench=BenchmarkEventUnmarshal -benchmem" +echo " go test -tags=benchcmp -bench=BenchmarkEventSign -benchmem" +echo " go test -tags=benchcmp -bench=BenchmarkEventVerify -benchmem" +echo " go test -tags=benchcmp -bench=BenchmarkFilterMatch -benchmem" +echo "" +echo -e "${BLUE}To compare specific libraries:${NC}" +echo " go test -tags=benchcmp -bench='.*_NWIO' -benchmem" +echo " go test -tags=benchcmp -bench='.*_NBD' -benchmem" +echo " go test -tags=benchcmp -bench='.*_Fiat' -benchmem" -- cgit v1.2.3