-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathrun-benchmarks.sh
More file actions
executable file
·114 lines (93 loc) · 3.67 KB
/
Copy pathrun-benchmarks.sh
File metadata and controls
executable file
·114 lines (93 loc) · 3.67 KB
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
#!/bin/bash
# Sequentially Benchmark Comparison Script
# This script runs benchmarks for all Sequentially implementations and generates a comparison report
set -e
# Colors for outputCodacy
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
echo -e "${BLUE}============================================${NC}"
echo -e "${BLUE} Sequentially Implementations Benchmark${NC}"
echo -e "${BLUE}============================================${NC}"
echo ""
# Create results directory with timestamp
TIMESTAMP=$(date +%Y%m%d_%H%M%S)
PROJECT_DIR="$(cd "$(dirname "$0")" && pwd)"
RESULTS_DIR="${PROJECT_DIR}/benchmark-results/${TIMESTAMP}"
mkdir -p "${RESULTS_DIR}"
echo -e "${YELLOW}Results will be saved to: ${RESULTS_DIR}${NC}"
echo ""
# Benchmark configurations
WARMUP_ITERATIONS=5
MEASUREMENT_ITERATIONS=10
FORKS=2
THREADS=1
echo -e "${GREEN}Benchmark Configuration:${NC}"
echo " - Warmup iterations: ${WARMUP_ITERATIONS}"
echo " - Measurement iterations: ${MEASUREMENT_ITERATIONS}"
echo " - Forks: ${FORKS}"
echo " - Threads: ${THREADS}"
echo ""
# Run benchmarks
echo -e "${YELLOW}Running benchmarks... (this will take several minutes)${NC}"
echo ""
sbt "project benchmark" "Jmh/run \
-i ${MEASUREMENT_ITERATIONS} \
-wi ${WARMUP_ITERATIONS} \
-f ${FORKS} \
-t ${THREADS} \
-rf json \
-rff ${RESULTS_DIR}/results.json \
Sequentially.*Benchmark" | tee "${RESULTS_DIR}/raw-output.txt"
echo ""
echo -e "${GREEN}✓ Benchmarks completed!${NC}"
echo ""
# Parse and display results
echo -e "${BLUE}============================================${NC}"
echo -e "${BLUE} Benchmark Results${NC}"
echo -e "${BLUE}============================================${NC}"
echo ""
# Extract results from JSON (if jq is available)
if command -v jq &> /dev/null; then
echo -e "${GREEN}Processing results...${NC}"
echo ""
# Create summary report
SUMMARY_FILE="${RESULTS_DIR}/summary.txt"
echo "Sequentially Implementation Benchmark Results" > "${SUMMARY_FILE}"
echo "Generated: $(date)" >> "${SUMMARY_FILE}"
echo "============================================" >> "${SUMMARY_FILE}"
echo "" >> "${SUMMARY_FILE}"
jq -r '.[] |
"Benchmark: \(.benchmark)
Mode: \(.mode)
Score: \(.primaryMetric.score) ± \(.primaryMetric.scoreError) \(.primaryMetric.scoreUnit)
Samples: \(.primaryMetric.scorePercentiles."0.0") (min) - \(.primaryMetric.scorePercentiles."100.0") (max)
----------------------------------------"' \
"${RESULTS_DIR}/results.json" | tee -a "${SUMMARY_FILE}"
echo "" | tee -a "${SUMMARY_FILE}"
echo "============================================" | tee -a "${SUMMARY_FILE}"
echo "Comparison (higher is better for throughput):" | tee -a "${SUMMARY_FILE}"
echo "============================================" | tee -a "${SUMMARY_FILE}"
# Sort by score descending
jq -r '.[] | "\(.primaryMetric.score)\t\(.benchmark)"' "${RESULTS_DIR}/results.json" | \
sort -rn | \
nl | \
tee -a "${SUMMARY_FILE}"
echo ""
echo -e "${GREEN}✓ Summary saved to: ${SUMMARY_FILE}${NC}"
else
echo -e "${YELLOW}⚠ jq not found. Install jq for detailed analysis: brew install jq${NC}"
echo -e "${YELLOW}Raw results available in: ${RESULTS_DIR}/results.json${NC}"
fi
echo ""
echo -e "${BLUE}============================================${NC}"
echo -e "${GREEN}All results saved to: ${RESULTS_DIR}${NC}"
echo -e "${BLUE}============================================${NC}"
echo ""
echo "Files generated:"
echo " - results.json : JMH raw results"
echo " - summary.txt : Human-readable summary"
echo " - raw-output.txt : Complete console output"
echo ""
echo -e "${GREEN}Done! 🎉${NC}"