@@ -15,17 +15,21 @@ YELLOW='\033[1;33m'
1515BLUE=' \033[0;34m'
1616NC=' \033[0m' # No Color
1717
18- # Configuration
19- BENCHMARK_COUNT=${BENCHMARK_COUNT:- 5}
20- BENCHMARK_TIME=${BENCHMARK_TIME:- 10s}
21- BENCHMARK_FILTER=${BENCHMARK_FILTER:- " BenchmarkOTelOverhead" }
18+ # Configuration (can be overridden via environment variables)
19+ # Optimized defaults: 3 iterations Γ 3s = statistically valid in ~5-8 minutes total
20+ BENCHMARK_COUNT=${BENCHMARK_COUNT:- 3} # Number of times to run each benchmark (3 is minimum for benchstat)
21+ BENCHMARK_TIME=${BENCHMARK_TIME:- 3s} # How long to run each benchmark (3s gives stable results)
22+ BENCHMARK_FILTER=${BENCHMARK_FILTER:- " BenchmarkOTelOverhead" } # Benchmark name filter
2223UPSTREAM_REMOTE=${UPSTREAM_REMOTE:- " upstream" }
2324UPSTREAM_BRANCH=${UPSTREAM_BRANCH:- " master" }
2425
2526echo -e " ${BLUE} ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ${NC} "
2627echo -e " ${BLUE} β Redis Go Client - OTel Observability Performance Comparison β${NC} "
2728echo -e " ${BLUE} ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ${NC} "
2829echo " "
30+ echo -e " ${BLUE} β±οΈ Estimated time: ~5-8 minutes (count=${BENCHMARK_COUNT} , time=${BENCHMARK_TIME} )${NC} "
31+ echo -e " ${YELLOW} π‘ Customize: BENCHMARK_COUNT=5 BENCHMARK_TIME=5s ./compare_perf.sh${NC} "
32+ echo " "
2933
3034# Check if benchstat is installed
3135if ! command -v benchstat & > /dev/null; then
4145
4246# Check if Redis is running
4347echo -e " ${BLUE} π Checking Redis connection...${NC} "
44- if ! timeout 2 bash -c " echo > /dev/tcp/localhost/6379" 2> /dev/null; then
48+
49+ # Try redis-cli first (works on both Linux and macOS)
50+ if command -v redis-cli & > /dev/null; then
51+ if redis-cli -h localhost -p 6379 ping & > /dev/null; then
52+ echo -e " ${GREEN} β
Redis is running${NC} "
53+ else
54+ echo -e " ${RED} β Redis is not running on localhost:6379${NC} "
55+ echo -e " ${YELLOW} π‘ Start Redis with: docker run -d -p 6379:6379 redis:latest${NC} "
56+ exit 1
57+ fi
58+ # Fallback to nc (netcat) - works on both Linux and macOS
59+ elif command -v nc & > /dev/null; then
60+ if nc -z localhost 6379 2> /dev/null; then
61+ echo -e " ${GREEN} β
Redis is running (detected via port check)${NC} "
62+ else
63+ echo -e " ${RED} β Redis is not running on localhost:6379${NC} "
64+ echo -e " ${YELLOW} π‘ Start Redis with: docker run -d -p 6379:6379 redis:latest${NC} "
65+ exit 1
66+ fi
67+ # Fallback to /dev/tcp (works on Linux with bash, not macOS)
68+ elif timeout 2 bash -c " echo > /dev/tcp/localhost/6379" 2> /dev/null; then
69+ echo -e " ${GREEN} β
Redis is running (detected via /dev/tcp)${NC} "
70+ else
4571 echo -e " ${RED} β Redis is not running on localhost:6379${NC} "
4672 echo -e " ${YELLOW} π‘ Start Redis with: docker run -d -p 6379:6379 redis:latest${NC} "
4773 exit 1
4874fi
49- echo -e " ${GREEN} β
Redis is running${NC} "
5075echo " "
5176
5277# Save current state
0 commit comments