117 lines
3.6 KiB
Bash
Executable File
117 lines
3.6 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# Hybrid Performance Benchmark Runner for Rhailib
|
|
# This script sets up the environment and runs the benchmarks
|
|
|
|
set -e
|
|
|
|
echo "🚀 Rhailib Hybrid Performance Benchmark Runner"
|
|
echo "=============================================="
|
|
|
|
# Check if Redis is running
|
|
echo "📡 Checking Redis connection..."
|
|
if ! redis-cli ping > /dev/null 2>&1; then
|
|
echo "❌ Redis is not running. Please start Redis server:"
|
|
echo " redis-server"
|
|
exit 1
|
|
fi
|
|
echo "✅ Redis is running"
|
|
|
|
# Check if we're in the right directory
|
|
if [ ! -f "Cargo.toml" ] || [ ! -d "scripts" ]; then
|
|
echo "❌ Please run this script from the rhailib root directory"
|
|
exit 1
|
|
fi
|
|
|
|
# Build the worker binary in release mode for performance
|
|
echo "🔨 Building worker binary in release mode..."
|
|
cd src/worker
|
|
cargo build --release --bin worker
|
|
cd ../..
|
|
echo "✅ Worker binary built (release mode)"
|
|
|
|
# Clear any existing Redis data
|
|
echo "🧹 Clearing Redis test data..."
|
|
redis-cli FLUSHDB > /dev/null
|
|
echo "✅ Redis data cleared"
|
|
|
|
# Parse command line arguments
|
|
BENCHMARK_TYPE="full"
|
|
TASK_COUNT=""
|
|
WORKER_COUNT=""
|
|
|
|
while [[ $# -gt 0 ]]; do
|
|
case $1 in
|
|
--demo)
|
|
BENCHMARK_TYPE="demo"
|
|
shift
|
|
;;
|
|
--quick)
|
|
BENCHMARK_TYPE="quick"
|
|
shift
|
|
;;
|
|
--tasks)
|
|
TASK_COUNT="$2"
|
|
shift 2
|
|
;;
|
|
--workers)
|
|
WORKER_COUNT="$2"
|
|
shift 2
|
|
;;
|
|
--help|-h)
|
|
echo "Usage: $0 [OPTIONS]"
|
|
echo ""
|
|
echo "Options:"
|
|
echo " --demo Run demo script instead of full benchmarks"
|
|
echo " --quick Run quick benchmarks (fewer configurations)"
|
|
echo " --tasks N Override task count for demo"
|
|
echo " --workers N Override worker count for demo"
|
|
echo " --help, -h Show this help message"
|
|
echo ""
|
|
echo "Examples:"
|
|
echo " $0 # Run full benchmarks"
|
|
echo " $0 --demo # Run demo script"
|
|
echo " $0 --quick # Run quick benchmarks"
|
|
echo " $0 --demo --tasks 50 --workers 4 # Custom demo"
|
|
exit 0
|
|
;;
|
|
*)
|
|
echo "❌ Unknown option: $1"
|
|
echo "Use --help for usage information"
|
|
exit 1
|
|
;;
|
|
esac
|
|
done
|
|
|
|
case $BENCHMARK_TYPE in
|
|
"demo")
|
|
echo "🎯 Running benchmark demo..."
|
|
if [ -n "$TASK_COUNT" ] || [ -n "$WORKER_COUNT" ]; then
|
|
echo "⚠️ Custom task/worker counts not yet supported in demo"
|
|
echo " Using default values (100 tasks, 2 workers)"
|
|
fi
|
|
cargo run --example run_benchmark_demo
|
|
;;
|
|
"quick")
|
|
echo "⚡ Running quick benchmarks..."
|
|
echo " This will test basic configurations only"
|
|
cargo bench --bench rhai_performance_bench -- --quick
|
|
;;
|
|
"full")
|
|
echo "🏁 Running full benchmark suite..."
|
|
echo " This may take several minutes..."
|
|
cargo bench --bench rhai_performance_bench
|
|
echo ""
|
|
echo "📊 Benchmark results saved to: target/criterion/"
|
|
echo " Open target/criterion/report/index.html to view detailed results"
|
|
;;
|
|
esac
|
|
|
|
echo ""
|
|
echo "🎉 Benchmark run completed!"
|
|
echo ""
|
|
echo "📈 Next steps:"
|
|
echo " • View HTML reports in target/criterion/report/"
|
|
echo " • Run 'cargo bench' for full Criterion benchmarks"
|
|
echo " • Run '$0 --demo' for a quick demonstration"
|
|
echo " • Check BENCHMARK_README.md for detailed documentation" |