Skip to content

Commit a6ebc87

Browse files
committed
Improve perf compatison script
1 parent 5d5dbb8 commit a6ebc87

File tree

1 file changed

+31
-6
lines changed

1 file changed

+31
-6
lines changed

β€Žcompare_perf.shβ€Ž

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,21 @@ YELLOW='\033[1;33m'
1515
BLUE='\033[0;34m'
1616
NC='\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
2223
UPSTREAM_REMOTE=${UPSTREAM_REMOTE:-"upstream"}
2324
UPSTREAM_BRANCH=${UPSTREAM_BRANCH:-"master"}
2425

2526
echo -e "${BLUE}╔════════════════════════════════════════════════════════════════╗${NC}"
2627
echo -e "${BLUE}β•‘ Redis Go Client - OTel Observability Performance Comparison β•‘${NC}"
2728
echo -e "${BLUE}╔════════════════════════════════════════════════════════════════╗${NC}"
2829
echo ""
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
3135
if ! command -v benchstat &> /dev/null; then
@@ -41,12 +45,33 @@ fi
4145

4246
# Check if Redis is running
4347
echo -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
4874
fi
49-
echo -e "${GREEN}βœ… Redis is running${NC}"
5075
echo ""
5176

5277
# Save current state

0 commit comments

Comments
Β (0)