#!/bin/bash # Destructor Crash Fix Verification Script # Purpose: Run 20 development build benchmarks to verify crash fix # Expected: 0% crash rate (previously 50%) echo "=========================================" echo "Destructor Crash Fix Verification" echo "=========================================" echo "Target: 20 successful runs" echo "Build Mode: Development (HAKMEM_BUILD_RELEASE=0)" echo "Expected Performance: ~30.7M ops/s" echo "" # Ensure we're in development build mode export HAKMEM_BUILD_RELEASE=0 # Arrays to store results declare -a throughputs declare -a statuses total_runs=20 success_count=0 crash_count=0 echo "Starting 20-run verification test..." echo "" for i in $(seq 1 $total_runs); do echo "=========================================" echo "Run $i/$total_runs" echo "=========================================" # Run the benchmark and capture output and exit code output=$(./larson_hakmem 1 10 1 1000 100 10000 42 2>&1) exit_code=$? # Check if benchmark completed successfully if echo "$output" | grep -q "Throughput" && [ $exit_code -eq 0 ]; then # Extract throughput value throughput=$(echo "$output" | grep "Throughput" | awk '{print $3}') throughputs+=("$throughput") statuses+=("SUCCESS") success_count=$((success_count + 1)) echo "✓ SUCCESS: $throughput ops/s" else throughputs+=("0") statuses+=("CRASH") crash_count=$((crash_count + 1)) echo "✗ CRASHED (exit code: $exit_code)" echo "Last few lines of output:" echo "$output" | tail -5 fi echo "" sleep 1 # Brief pause between runs done echo "" echo "=========================================" echo "FINAL RESULTS SUMMARY" echo "=========================================" echo "" echo "Execution Statistics:" echo " Total Runs: $total_runs" echo " Successful: $success_count" echo " Crashed: $crash_count" echo " Success Rate: $(awk "BEGIN {printf \"%.1f%%\", ($success_count/$total_runs)*100}")" echo " Crash Rate: $(awk "BEGIN {printf \"%.1f%%\", ($crash_count/$total_runs)*100}")" echo "" if [ $success_count -gt 0 ]; then echo "Performance Statistics (Successful Runs):" # Calculate mean sum=0 for tp in "${throughputs[@]}"; do if [ "$tp" != "0" ]; then sum=$(awk "BEGIN {print $sum + $tp}") fi done mean=$(awk "BEGIN {printf \"%.2f\", $sum/$success_count}") echo " Mean: $mean M ops/s" # Calculate min and max min=999999999 max=0 for tp in "${throughputs[@]}"; do if [ "$tp" != "0" ]; then if (( $(awk "BEGIN {print ($tp < $min)}") )); then min=$tp fi if (( $(awk "BEGIN {print ($tp > $max)}") )); then max=$tp fi fi done echo " Min: $min M ops/s" echo " Max: $max M ops/s" echo " Range: $(awk "BEGIN {printf \"%.2f\", $max - $min}") M ops/s" # Calculate standard deviation variance=0 for tp in "${throughputs[@]}"; do if [ "$tp" != "0" ]; then diff=$(awk "BEGIN {print $tp - $mean}") variance=$(awk "BEGIN {print $variance + ($diff * $diff)}") fi done variance=$(awk "BEGIN {print $variance / $success_count}") stddev=$(awk "BEGIN {printf \"%.2f\", sqrt($variance)}") echo " Std Deviation: $stddev M ops/s" # Calculate coefficient of variation cv=$(awk "BEGIN {printf \"%.2f%%\", ($stddev/$mean)*100}") echo " Variation: $cv" # Compare to expected performance expected=30.7 deviation=$(awk "BEGIN {printf \"%.2f%%\", (($mean - $expected)/$expected)*100}") echo "" echo "Comparison to Phase 4a Baseline (30.7M ops/s):" echo " Deviation: $deviation" fi echo "" echo "Detailed Run-by-Run Results:" echo "Run# Status Throughput (M ops/s)" echo "---- ------- -------------------" for i in $(seq 0 $((total_runs - 1))); do status="${statuses[$i]}" tp="${throughputs[$i]}" if [ "$tp" == "0" ]; then printf "%-4d %-7s %s\n" $((i + 1)) "$status" "N/A" else printf "%-4d %-7s %s\n" $((i + 1)) "$status" "$tp" fi done echo "" echo "=========================================" echo "VERIFICATION CONCLUSION" echo "=========================================" if [ $crash_count -eq 0 ]; then echo "✓ PASS: No crashes detected in 20 runs" echo " Previous crash rate: 50%" echo " Current crash rate: 0%" echo " Improvement: 100% crash elimination" else echo "✗ FAIL: Crashes still occurring" echo " Expected: 0 crashes" echo " Actual: $crash_count crashes" echo " This indicates the fix may be incomplete" fi echo "" echo "Test completed at $(date)" echo "========================================="