summaryrefslogtreecommitdiffstats
path: root/run_benchmarks.sh
blob: 87dfd1780a942575096e61781d556097fb576d88 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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"