forked from Haigutus/cim-bench
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_benchmarks.sh
More file actions
executable file
Β·135 lines (114 loc) Β· 3.86 KB
/
run_benchmarks.sh
File metadata and controls
executable file
Β·135 lines (114 loc) Β· 3.86 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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
#!/usr/bin/env bash
#
# Run all CIM-bench benchmarks and generate reports (Python-only)
#
# This script runs ONLY native Python benchmarks. Docker-only benchmarks
# (prefixed with docker_*) require JPype+JVM and must be run via:
# ./docker/run_benchmark.sh
#
# Usage:
# ./run_benchmarks.sh [--quick] [--skip-existing]
#
# Options:
# --quick Run minimal rounds for faster iteration
# --skip-existing Skip benchmarks if JSON results already exist
#
set -e
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "$SCRIPT_DIR"
RESULTS_DIR="results"
BENCHMARK_OPTS=""
SKIP_EXISTING=false
# Parse arguments
for arg in "$@"; do
case "$arg" in
--quick)
BENCHMARK_OPTS="--benchmark-min-rounds=3"
echo "Running in quick mode (minimal rounds)"
;;
--skip-existing)
SKIP_EXISTING=true
echo "Skip mode enabled (existing results will be reused)"
;;
esac
done
# Create results directory
mkdir -p "$RESULTS_DIR"
echo "=================================="
echo "CIM-bench Benchmark Suite"
echo "=================================="
echo ""
# Auto-discover all benchmark files
echo "π Discovering benchmarks..."
BENCHMARK_FILES=(benchmarks/*_benchmark.py)
echo "Found ${#BENCHMARK_FILES[@]} benchmark files"
echo ""
# Run each benchmark
for test_file in "${BENCHMARK_FILES[@]}"; do
# Skip if not a file
[[ -f "$test_file" ]] || continue
# Skip test_ prefixed files (unit tests, not benchmarks)
basename="${test_file##*/}"
[[ "$basename" == test_* ]] && continue
# Skip docker_ prefixed files (Docker-only benchmarks requiring JPype+JVM)
[[ "$basename" == docker_* ]] && continue
# Extract basename for output file
output_json="$RESULTS_DIR/${basename%.py}.json"
# Skip if results already exist and --skip-existing flag is set
if [[ "$SKIP_EXISTING" == true && -f "$output_json" ]]; then
echo "βοΈ Skipping ${basename} (results exist)"
continue
fi
echo "π Running ${basename}..."
uv run pytest "$test_file" \
--benchmark-only \
--benchmark-json="$output_json" \
$BENCHMARK_OPTS
echo "β
${basename} complete"
echo ""
done
# Generate markdown reports from all JSON files
echo "π Generating markdown reports..."
for json_file in "$RESULTS_DIR"/*_benchmark.json; do
[[ -f "$json_file" ]] || continue
# Skip test_ and docker_ prefixed files
basename_json="$(basename "$json_file")"
[[ "$basename_json" == test_* ]] && continue
[[ "$basename_json" == docker_* ]] && continue
report_file="${json_file%.json}_report.md"
uv run python tools/generate_report.py "$json_file" "$report_file"
echo " β $(basename "$report_file")"
done
echo ""
# Generate comparison summary
BENCHMARK_JSONS=("$RESULTS_DIR"/*_benchmark.json)
if [ ${#BENCHMARK_JSONS[@]} -gt 1 ]; then
echo "π Generating comparison summary..."
uv run python tools/generate_comparison.py "${BENCHMARK_JSONS[@]}" "$RESULTS_DIR/comparison_summary.md"
echo " β comparison_summary.md"
echo ""
fi
# Generate visualizations (if matplotlib available)
if uv run python -c "import matplotlib" 2>/dev/null; then
uv run python tools/generate_graphs.py
else
echo "β οΈ Matplotlib not installed - skipping graph generation"
echo " Install with: uv sync --extra visualization"
echo ""
fi
echo "=================================="
echo "β
All benchmarks complete!"
echo "=================================="
echo ""
echo "Results available in: $RESULTS_DIR/"
echo ""
echo "Reports:"
for report in "$RESULTS_DIR"/*_report.md; do
[[ -f "$report" ]] || continue
# Skip test_ and docker_ prefixed files
basename_report="$(basename "$report")"
[[ "$basename_report" == test_* ]] && continue
[[ "$basename_report" == docker_* ]] && continue
echo " - $basename_report"
done
echo ""