wifi-densepose/vendor/midstream/scripts/run_benchmarks.sh

176 lines
5.2 KiB
Bash
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/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! ๐ŸŽ‰"