Makefile raw

   1  .PHONY: help bench bench-all bench-pubkey bench-sign bench-verify bench-ecdh clean install
   2  
   3  # Default target
   4  help:
   5  	@echo "Secp256k1 Implementation Benchmark Suite"
   6  	@echo ""
   7  	@echo "Available targets:"
   8  	@echo "  bench            - Run all comparative benchmarks (10s each)"
   9  	@echo "  bench-all        - Run all benchmarks with statistical analysis"
  10  	@echo "  bench-pubkey     - Benchmark public key derivation"
  11  	@echo "  bench-sign       - Benchmark Schnorr signing"
  12  	@echo "  bench-verify     - Benchmark Schnorr verification"
  13  	@echo "  bench-ecdh       - Benchmark ECDH key exchange"
  14  	@echo "  bench-quick      - Quick benchmark run (1s each)"
  15  	@echo "  install          - Install benchmark dependencies"
  16  	@echo "  clean            - Clean benchmark results"
  17  	@echo ""
  18  	@echo "Environment variables:"
  19  	@echo "  BENCHTIME        - Duration for each benchmark (default: 10s)"
  20  	@echo "  COUNT            - Number of iterations (default: 5)"
  21  
  22  # Run all comparative benchmarks
  23  bench:
  24  	go test -bench=BenchmarkAll -benchmem -benchtime=10s
  25  
  26  # Quick benchmark (1 second each)
  27  bench-quick:
  28  	go test -bench=BenchmarkComparative -benchmem -benchtime=1s
  29  
  30  # Run all benchmarks with detailed output
  31  bench-all:
  32  	./run_benchmarks.sh
  33  
  34  # Individual operation benchmarks
  35  bench-pubkey:
  36  	go test -bench=BenchmarkComparative_PubkeyDerivation -benchmem -benchtime=10s
  37  
  38  bench-sign:
  39  	go test -bench=BenchmarkComparative_SchnorrSign -benchmem -benchtime=10s
  40  
  41  bench-verify:
  42  	go test -bench=BenchmarkComparative_SchnorrVerify -benchmem -benchtime=10s
  43  
  44  bench-ecdh:
  45  	go test -bench=BenchmarkComparative_ECDH -benchmem -benchtime=10s
  46  
  47  # Run BTCEC-only benchmarks
  48  bench-btcec:
  49  	go test -bench=BenchmarkBTCEC -benchmem -benchtime=5s
  50  
  51  # Run P256K1-only benchmarks
  52  bench-p256k1:
  53  	go test -bench=BenchmarkP256K1 -benchmem -benchtime=5s
  54  
  55  # Run P8K-only benchmarks
  56  bench-p8k:
  57  	go test -bench=BenchmarkP8K -benchmem -benchtime=5s
  58  
  59  # Install dependencies
  60  install:
  61  	go get -u ./...
  62  	go mod tidy
  63  	@echo "Installing benchstat for statistical analysis..."
  64  	@go install golang.org/x/perf/cmd/benchstat@latest || echo "Note: benchstat install failed, but benchmarks will still work"
  65  
  66  # Clean results
  67  clean:
  68  	rm -rf results/
  69  	go clean -testcache
  70  
  71  # Show module info
  72  info:
  73  	@echo "Benchmark module information:"
  74  	@go list -m all
  75  
  76