#!/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"