fix: restore localized samples in tests (#749)

* fix: restore required localized examples

* style: fix formatting issues
This commit is contained in:
安正超
2025-10-29 13:16:31 +08:00
committed by GitHub
parent 64ba52bc1e
commit dd47fcf2a8
41 changed files with 1294 additions and 3312 deletions

View File

@@ -1,18 +1,18 @@
#!/bin/bash
# Scanner性能优化基准测试运行脚本
# 使用方法: ./scripts/run_scanner_benchmarks.sh [test_type] [quick]
# Scanner performance benchmark runner
# Usage: ./scripts/run_scanner_benchmarks.sh [test_type] [quick]
set -e
WORKSPACE_ROOT="/home/dandan/code/rust/rustfs"
cd "$WORKSPACE_ROOT"
# 基本参数
# Default parameters
QUICK_MODE=false
TEST_TYPE="all"
# 解析命令行参数
# Parse command-line arguments
if [[ "$1" == "quick" ]] || [[ "$2" == "quick" ]]; then
QUICK_MODE=true
fi
@@ -21,116 +21,116 @@ if [[ -n "$1" ]] && [[ "$1" != "quick" ]]; then
TEST_TYPE="$1"
fi
# 快速模式的基准测试参数
# Benchmark options for quick mode
if [[ "$QUICK_MODE" == "true" ]]; then
BENCH_ARGS="--sample-size 10 --warm-up-time 1 --measurement-time 2"
echo "🚀 运行快速基准测试模式..."
echo "🚀 Running benchmarks in quick mode..."
else
BENCH_ARGS=""
echo "🏃 运行完整基准测试模式..."
echo "🏃 Running the full benchmark suite..."
fi
echo "📊 Scanner性能优化基准测试"
echo "工作目录: $WORKSPACE_ROOT"
echo "测试类型: $TEST_TYPE"
echo "快速模式: $QUICK_MODE"
echo "📊 Scanner performance benchmarks"
echo "Working directory: $WORKSPACE_ROOT"
echo "Selected benchmark group: $TEST_TYPE"
echo "Quick mode: $QUICK_MODE"
echo "="
# 检查编译状态
echo "🔧 检查编译状态..."
# Verify the workspace compiles
echo "🔧 Checking compilation status..."
if ! cargo check --package rustfs-ahm --benches --quiet; then
echo "❌ 基准测试编译失败"
echo "❌ Benchmark compilation failed"
exit 1
fi
echo "✅ 编译检查通过"
echo "✅ Compilation succeeded"
# 基准测试函数
# Helper to run an individual benchmark target
run_benchmark() {
local bench_name=$1
local description=$2
echo ""
echo "🧪 运行 $description"
echo "基准测试: $bench_name"
echo "参数: $BENCH_ARGS"
echo "🧪 Running $description"
echo "Benchmark: $bench_name"
echo "Arguments: $BENCH_ARGS"
if timeout 300 cargo bench --package rustfs-ahm --bench "$bench_name" -- $BENCH_ARGS; then
echo "$description 完成"
echo "$description finished"
else
echo "⚠️ $description 运行超时或失败"
echo "⚠️ $description timed out or failed"
return 1
fi
}
# 运行指定的基准测试
# Dispatch benchmarks based on the requested test type
case "$TEST_TYPE" in
"business" | "business_io")
run_benchmark "business_io_impact" "业务IO影响测试"
run_benchmark "business_io_impact" "Business I/O impact"
;;
"scanner" | "performance")
run_benchmark "scanner_performance" "Scanner性能测试"
run_benchmark "scanner_performance" "Scanner performance"
;;
"resource" | "contention")
run_benchmark "resource_contention" "资源竞争测试"
run_benchmark "resource_contention" "Resource contention"
;;
"adaptive" | "scheduling")
run_benchmark "adaptive_scheduling" "智能调度测试"
run_benchmark "adaptive_scheduling" "Adaptive scheduling"
;;
"list")
echo "📋 列出所有可用的基准测试:"
echo "📋 Available benchmarks:"
cargo bench --package rustfs-ahm -- --list
;;
"all")
echo "🚀 运行所有基准测试..."
echo "🚀 Running the full benchmark suite..."
echo ""
echo "=== 1/4 业务IO影响测试 ==="
if ! run_benchmark "business_io_impact" "业务IO影响测试"; then
echo "⚠️ 业务IO影响测试失败继续运行其他测试..."
echo "=== 1/4 Business I/O impact ==="
if ! run_benchmark "business_io_impact" "Business I/O impact"; then
echo "⚠️ Business I/O impact benchmark failed, continuing..."
fi
echo ""
echo "=== 2/4 Scanner性能测试 ==="
if ! run_benchmark "scanner_performance" "Scanner性能测试"; then
echo "⚠️ Scanner性能测试失败,继续运行其他测试..."
echo "=== 2/4 Scanner performance ==="
if ! run_benchmark "scanner_performance" "Scanner performance"; then
echo "⚠️ Scanner performance benchmark failed, continuing..."
fi
echo ""
echo "=== 3/4 资源竞争测试 ==="
if ! run_benchmark "resource_contention" "资源竞争测试"; then
echo "⚠️ 资源竞争测试失败,继续运行其他测试..."
echo "=== 3/4 Resource contention ==="
if ! run_benchmark "resource_contention" "Resource contention"; then
echo "⚠️ Resource contention benchmark failed, continuing..."
fi
echo ""
echo "=== 4/4 智能调度测试 ==="
if ! run_benchmark "adaptive_scheduling" "智能调度测试"; then
echo "⚠️ 智能调度测试失败"
echo "=== 4/4 Adaptive scheduling ==="
if ! run_benchmark "adaptive_scheduling" "Adaptive scheduling"; then
echo "⚠️ Adaptive scheduling benchmark failed"
fi
;;
*)
echo "未知的测试类型: $TEST_TYPE"
echo "Unknown test type: $TEST_TYPE"
echo ""
echo "用法: $0 [test_type] [quick]"
echo "Usage: $0 [test_type] [quick]"
echo ""
echo "测试类型:"
echo " all - 运行所有基准测试 (默认)"
echo " business|business_io - 业务IO影响测试"
echo " scanner|performance - Scanner性能测试"
echo " resource|contention - 资源竞争测试"
echo " adaptive|scheduling - 智能调度测试"
echo " list - 列出所有可用测试"
echo "Available test types:"
echo " all - run the entire benchmark suite (default)"
echo " business|business_io - business I/O impact benchmark"
echo " scanner|performance - scanner performance benchmark"
echo " resource|contention - resource contention benchmark"
echo " adaptive|scheduling - adaptive scheduling benchmark"
echo " list - list all benchmarks"
echo ""
echo "选项:"
echo " quick - 快速模式 (减少样本数和测试时间)"
echo "Options:"
echo " quick - quick mode (smaller sample size and duration)"
echo ""
echo "示例:"
echo " $0 business quick - 快速运行业务IO测试"
echo " $0 all - 运行所有完整测试"
echo " $0 list - 列出所有测试"
echo "Examples:"
echo " $0 business quick - run the business I/O benchmark in quick mode"
echo " $0 all - run every benchmark"
echo " $0 list - list available benchmarks"
exit 1
;;
esac
echo ""
echo "🎉 基准测试脚本执行完成!"
echo "📊 查看结果: target/criterion/ 目录下有详细的HTML报告"
echo "🎉 Benchmark script finished!"
echo "📊 Detailed HTML reports are available under target/criterion/"