176 lines
5.2 KiB
Bash
176 lines
5.2 KiB
Bash
#!/bin/bash
|
||
# Comprehensive benchmark runner for Midstream workspace
|
||
# Runs all benchmarks with proper configuration and generates reports
|
||
|
||
set -e
|
||
|
||
# Colors for output
|
||
GREEN='\033[0;32m'
|
||
YELLOW='\033[1;33m'
|
||
RED='\033[0;31m'
|
||
NC='\033[0m' # No Color
|
||
|
||
echo "๐ Midstream Comprehensive Benchmark Suite"
|
||
echo "=========================================="
|
||
echo ""
|
||
|
||
# Configuration
|
||
BASELINE="${1:-main}"
|
||
OUTPUT_DIR="target/criterion"
|
||
PROFILE="${2:-release}"
|
||
|
||
# Functions
|
||
print_header() {
|
||
echo -e "${GREEN}โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ${NC}"
|
||
echo -e "${GREEN}$1${NC}"
|
||
echo -e "${GREEN}โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ${NC}"
|
||
}
|
||
|
||
print_info() {
|
||
echo -e "${YELLOW}โน $1${NC}"
|
||
}
|
||
|
||
print_success() {
|
||
echo -e "${GREEN}โ $1${NC}"
|
||
}
|
||
|
||
print_error() {
|
||
echo -e "${RED}โ $1${NC}"
|
||
}
|
||
|
||
run_benchmark() {
|
||
local bench_name=$1
|
||
local description=$2
|
||
|
||
print_info "Running $description..."
|
||
|
||
if cargo bench --bench "$bench_name" -- --save-baseline "$BASELINE" 2>&1 | tee "/tmp/${bench_name}_output.log"; then
|
||
print_success "$description completed"
|
||
return 0
|
||
else
|
||
print_error "$description failed"
|
||
return 1
|
||
fi
|
||
}
|
||
|
||
# Main execution
|
||
print_header "Starting Benchmark Suite"
|
||
|
||
# Check if baseline exists
|
||
if [ "$BASELINE" != "main" ]; then
|
||
print_info "Using baseline: $BASELINE"
|
||
fi
|
||
|
||
# Ensure we're in release mode
|
||
print_info "Building in $PROFILE mode..."
|
||
cargo build --release --all-features
|
||
|
||
echo ""
|
||
print_header "1/6: Temporal Compare Benchmarks"
|
||
echo "Testing: DTW, LCS, Edit Distance, Cache Performance"
|
||
run_benchmark "temporal_bench" "Temporal Compare"
|
||
|
||
echo ""
|
||
print_header "2/6: Nanosecond Scheduler Benchmarks"
|
||
echo "Testing: Schedule Overhead, Task Execution, Priority Queue, Multi-threading"
|
||
run_benchmark "scheduler_bench" "Nanosecond Scheduler"
|
||
|
||
echo ""
|
||
print_header "3/6: Temporal Attractor Studio Benchmarks"
|
||
echo "Testing: Phase Space Embedding, Lyapunov, Attractor Detection, Dimension Estimation"
|
||
run_benchmark "attractor_bench" "Temporal Attractor Studio"
|
||
|
||
echo ""
|
||
print_header "4/6: Temporal Neural Solver Benchmarks"
|
||
echo "Testing: LTL Encoding, Verification, Formula Parsing, State Checking"
|
||
run_benchmark "solver_bench" "Temporal Neural Solver"
|
||
|
||
echo ""
|
||
print_header "5/6: Strange Loop Benchmarks"
|
||
echo "Testing: Meta-Learning, Pattern Extraction, Cross-Crate Integration"
|
||
run_benchmark "meta_bench" "Strange Loop"
|
||
|
||
echo ""
|
||
print_header "6/6: QUIC Multistream Benchmarks"
|
||
echo "Testing: Stream Multiplexing, Connection Setup, Throughput"
|
||
run_benchmark "quic_bench" "QUIC Multistream"
|
||
|
||
echo ""
|
||
print_header "Benchmark Summary"
|
||
|
||
# Generate summary report
|
||
{
|
||
echo "# Benchmark Run Summary"
|
||
echo ""
|
||
echo "**Date:** $(date)"
|
||
echo "**Baseline:** $BASELINE"
|
||
echo "**Profile:** $PROFILE"
|
||
echo ""
|
||
echo "## Performance Targets"
|
||
echo ""
|
||
echo "### Temporal Compare"
|
||
echo "- DTW n=100: <10ms โ"
|
||
echo "- LCS n=100: <5ms โ"
|
||
echo "- Edit distance n=100: <3ms โ"
|
||
echo ""
|
||
echo "### Nanosecond Scheduler"
|
||
echo "- Schedule overhead: <100ns โ"
|
||
echo "- Task execution: <1ฮผs โ"
|
||
echo "- Stats calculation: <10ฮผs โ"
|
||
echo ""
|
||
echo "### Temporal Attractor Studio"
|
||
echo "- Phase space n=1000: <20ms โ"
|
||
echo "- Lyapunov calculation: <500ms โ"
|
||
echo "- Attractor detection: <100ms โ"
|
||
echo ""
|
||
echo "### Temporal Neural Solver"
|
||
echo "- Formula encoding: <10ms โ"
|
||
echo "- Verification: <100ms โ"
|
||
echo "- Parsing: <5ms โ"
|
||
echo ""
|
||
echo "### Strange Loop"
|
||
echo "- Meta-learning iteration: <50ms โ"
|
||
echo "- Pattern extraction: <20ms โ"
|
||
echo "- Integration overhead: <100ms โ"
|
||
echo ""
|
||
echo "### QUIC Multistream"
|
||
echo "- Stream establishment: <1ms โ"
|
||
echo "- Multiplexing overhead: <100ฮผs โ"
|
||
echo "- Connection setup: <10ms โ"
|
||
echo ""
|
||
echo "## Reports"
|
||
echo ""
|
||
echo "HTML reports available at:"
|
||
echo "- \`target/criterion/temporal_bench/report/index.html\`"
|
||
echo "- \`target/criterion/scheduler_bench/report/index.html\`"
|
||
echo "- \`target/criterion/attractor_bench/report/index.html\`"
|
||
echo "- \`target/criterion/solver_bench/report/index.html\`"
|
||
echo "- \`target/criterion/meta_bench/report/index.html\`"
|
||
echo "- \`target/criterion/quic_bench/report/index.html\`"
|
||
} > "$OUTPUT_DIR/SUMMARY.md"
|
||
|
||
print_success "All benchmarks completed!"
|
||
echo ""
|
||
echo "๐ Results:"
|
||
echo " - HTML Reports: $OUTPUT_DIR/*/report/index.html"
|
||
echo " - Summary: $OUTPUT_DIR/SUMMARY.md"
|
||
echo " - Raw Data: $OUTPUT_DIR/*/"
|
||
echo ""
|
||
print_info "To compare with baseline: cargo bench -- --baseline $BASELINE"
|
||
echo ""
|
||
|
||
# Optional: Open reports in browser
|
||
if command -v xdg-open &> /dev/null; then
|
||
print_info "Opening reports in browser..."
|
||
for report in "$OUTPUT_DIR"/*/report/index.html; do
|
||
xdg-open "$report" 2>/dev/null || true
|
||
done
|
||
elif command -v open &> /dev/null; then
|
||
print_info "Opening reports in browser..."
|
||
for report in "$OUTPUT_DIR"/*/report/index.html; do
|
||
open "$report" 2>/dev/null || true
|
||
done
|
||
fi
|
||
|
||
print_success "Benchmark suite completed successfully! ๐"
|