-
Notifications
You must be signed in to change notification settings - Fork 345
Expand file tree
/
Copy pathrun-benchmarks.sh
More file actions
executable file
·88 lines (78 loc) · 2.67 KB
/
run-benchmarks.sh
File metadata and controls
executable file
·88 lines (78 loc) · 2.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
#!/bin/bash
# Edge-Net Performance Benchmark Runner
# Usage: ./run-benchmarks.sh [--baseline|--compare|--profile]
set -e
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "$SCRIPT_DIR"
echo "========================================"
echo "Edge-Net Performance Benchmark Suite"
echo "========================================"
echo ""
# Check if cargo bench is available
if ! command -v cargo &> /dev/null; then
echo "Error: cargo not found. Please install Rust toolchain."
exit 1
fi
# Parse arguments
MODE="run"
if [ "$1" == "--baseline" ]; then
MODE="baseline"
elif [ "$1" == "--compare" ]; then
MODE="compare"
elif [ "$1" == "--profile" ]; then
MODE="profile"
fi
case $MODE in
baseline)
echo "Creating performance baseline..."
cargo bench --features=bench 2>&1 | tee benchmarks-baseline.txt
echo ""
echo "✅ Baseline saved to: benchmarks-baseline.txt"
;;
compare)
if [ ! -f "benchmarks-baseline.txt" ]; then
echo "Error: No baseline found. Run with --baseline first."
exit 1
fi
echo "Running benchmarks and comparing with baseline..."
cargo bench --features=bench 2>&1 | tee benchmarks-current.txt
echo ""
echo "Comparison Report:"
echo "=================="
echo "Baseline file: benchmarks-baseline.txt"
echo "Current file: benchmarks-current.txt"
echo ""
echo "To compare, install cargo-benchcmp:"
echo " cargo install cargo-benchcmp"
echo " cargo benchcmp benchmarks-baseline.txt benchmarks-current.txt"
;;
profile)
echo "Running with profiling (flamegraph)..."
if ! command -v cargo-flamegraph &> /dev/null; then
echo "Installing cargo-flamegraph..."
cargo install flamegraph
fi
cargo flamegraph --bench benchmarks --features=bench
echo ""
echo "✅ Flamegraph saved to: flamegraph.svg"
echo "Open with: firefox flamegraph.svg (or your browser)"
;;
*)
echo "Running all benchmarks..."
echo ""
cargo bench --features=bench
echo ""
echo "✅ Benchmarks complete!"
echo ""
echo "Usage:"
echo " ./run-benchmarks.sh # Run benchmarks"
echo " ./run-benchmarks.sh --baseline # Save baseline"
echo " ./run-benchmarks.sh --compare # Compare with baseline"
echo " ./run-benchmarks.sh --profile # Generate flamegraph"
;;
esac
echo ""
echo "Performance reports available:"
echo " - PERFORMANCE_ANALYSIS.md"
echo " - OPTIMIZATIONS_APPLIED.md"
echo " - OPTIMIZATION_SUMMARY.md"