diff options
| author | bndw <ben@bdw.to> | 2026-02-14 18:56:19 -0800 |
|---|---|---|
| committer | bndw <ben@bdw.to> | 2026-02-14 18:56:19 -0800 |
| commit | 7a5d5a53e5d6878f38382c4d35f644e088d318d2 (patch) | |
| tree | 5f8ba0bee800a5998ec4167c47e4adc6602243e1 /run_benchmarks.sh | |
| parent | 7fba76d7e4e63e0c29da81d6be43330743af1aaf (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-x | run_benchmarks.sh | 35 |
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 | ||
| 2 | set -e | ||
| 3 | |||
| 4 | # Colors for output | ||
| 5 | GREEN='\033[0;32m' | ||
| 6 | BLUE='\033[0;34m' | ||
| 7 | YELLOW='\033[1;33m' | ||
| 8 | NC='\033[0m' # No Color | ||
| 9 | |||
| 10 | echo -e "${BLUE}Running Nostr Library Benchmarks${NC}" | ||
| 11 | echo -e "${BLUE}Comparing: NWIO vs NBD-WTF vs Fiatjaf${NC}" | ||
| 12 | echo "" | ||
| 13 | |||
| 14 | # First, install comparison dependencies if needed | ||
| 15 | echo -e "${YELLOW}Ensuring comparison dependencies are available...${NC}" | ||
| 16 | go get -tags=benchcmp -t ./... | ||
| 17 | echo "" | ||
| 18 | |||
| 19 | # Run all benchmarks with the benchcmp build tag | ||
| 20 | echo -e "${GREEN}Running all benchmarks...${NC}" | ||
| 21 | go test -tags=benchcmp -bench=. -benchmem -benchtime=1s -run=^$ | tee benchmark_results.txt | ||
| 22 | |||
| 23 | echo "" | ||
| 24 | echo -e "${GREEN}Results saved to benchmark_results.txt${NC}" | ||
| 25 | echo "" | ||
| 26 | echo -e "${BLUE}To run specific benchmark groups:${NC}" | ||
| 27 | echo " go test -tags=benchcmp -bench=BenchmarkEventUnmarshal -benchmem" | ||
| 28 | echo " go test -tags=benchcmp -bench=BenchmarkEventSign -benchmem" | ||
| 29 | echo " go test -tags=benchcmp -bench=BenchmarkEventVerify -benchmem" | ||
| 30 | echo " go test -tags=benchcmp -bench=BenchmarkFilterMatch -benchmem" | ||
| 31 | echo "" | ||
| 32 | echo -e "${BLUE}To compare specific libraries:${NC}" | ||
| 33 | echo " go test -tags=benchcmp -bench='.*_NWIO' -benchmem" | ||
| 34 | echo " go test -tags=benchcmp -bench='.*_NBD' -benchmem" | ||
| 35 | echo " go test -tags=benchcmp -bench='.*_Fiat' -benchmem" | ||
