Files
hakmem/run_pool_bench.sh

93 lines
2.8 KiB
Bash
Raw Normal View History

#!/usr/bin/env bash
# run_pool_bench.sh - Pool TLS Phase 1.5a パフォーマンステスト
#
# Pool TLS の性能を System malloc / mimalloc と比較
set -euo pipefail
echo "========================================="
echo " 🧪 Pool TLS Phase 1.5a Benchmark"
echo "========================================="
echo ""
# 1. Build Pool TLS version
echo "📦 Building Pool TLS Phase 1.5a..."
./build_pool_tls.sh bench_mid_large_mt_hakmem >/dev/null 2>&1
echo "✓ HAKMEM built"
# 2. Build System malloc version
echo "📦 Building System malloc version..."
./build.sh bench_mid_large_mt_system >/dev/null 2>&1
echo "✓ System malloc built"
echo ""
echo "========================================="
echo " 📊 Running Benchmarks"
echo "========================================="
echo ""
# Test parameters
THREADS=1
CYCLES=100000
WORKSET=256
SEED=42
# Run HAKMEM
echo "🔵 HAKMEM (Pool TLS Phase 1.5a)..."
HAKMEM_OUTPUT=$(./bench_mid_large_mt_hakmem $THREADS $CYCLES $WORKSET $SEED 2>&1)
HAKMEM_RESULT=$(echo "$HAKMEM_OUTPUT" | grep "Throughput" | awk '{print $3}')
HAKMEM_TIME=$(echo "$HAKMEM_OUTPUT" | grep "Throughput" | awk '{print $NF}' | tr -d 's.')
# Run System
echo "🟢 System malloc..."
SYSTEM_OUTPUT=$(./bench_mid_large_mt_system $THREADS $CYCLES $WORKSET $SEED 2>&1)
SYSTEM_RESULT=$(echo "$SYSTEM_OUTPUT" | grep "Throughput" | awk '{print $3}')
SYSTEM_TIME=$(echo "$SYSTEM_OUTPUT" | grep "Throughput" | awk '{print $NF}' | tr -d 's.')
# Calculate performance ratio
RATIO=$(echo "scale=2; $HAKMEM_RESULT / $SYSTEM_RESULT * 100" | bc)
SPEEDUP=$(echo "scale=2; $HAKMEM_RESULT / $SYSTEM_RESULT" | bc)
# Determine status emoji
if (( $(echo "$RATIO >= 100" | bc -l) )); then
STATUS="🏆"
VERDICT="HAKMEM WINS!"
elif (( $(echo "$RATIO >= 80" | bc -l) )); then
STATUS="✅"
VERDICT="Competitive"
elif (( $(echo "$RATIO >= 50" | bc -l) )); then
STATUS="⚠️ "
VERDICT="Below target"
else
STATUS="❌"
VERDICT="Needs optimization"
fi
# Pretty print results
echo ""
echo "========================================="
echo " 📊 Performance Results"
echo "========================================="
printf "%-25s %12s ops/s (%.3fs)\n" "HAKMEM (Pool TLS):" "$HAKMEM_RESULT" "$HAKMEM_TIME"
printf "%-25s %12s ops/s (%.3fs)\n" "System malloc:" "$SYSTEM_RESULT" "$SYSTEM_TIME"
echo "----------------------------------------"
printf "%-25s %11s%% (${SPEEDUP}x)\n" "Performance ratio:" "$RATIO"
echo "========================================="
echo " $STATUS $VERDICT"
echo "========================================="
echo ""
# Expected performance targets
echo "📈 Pool TLS Phase 1.5a Targets:"
echo " - Current: 1.0-2.0M ops/s (baseline)"
echo " - Phase 1.5b: 5-15M ops/s (with optimizations)"
echo " - Phase 2: 15-30M ops/s (full learning)"
echo ""
# Exit code based on performance
if (( $(echo "$RATIO >= 50" | bc -l) )); then
exit 0
else
exit 1
fi