#!/bin/bash # Update all report files with correct data from test results SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" cd "$SCRIPT_DIR" # Function to extract data from test output and create report create_report() { local decimals=$1 local input_file="reports/run_${decimals}_output.txt" local output_file="reports/${decimals}_decimals.md" if [ ! -f "$input_file" ]; then echo "Warning: $input_file not found" return fi echo "Creating report for $decimals decimals..." # Create report header cat > "$output_file" << EOF # Performance Report: $decimals Decimal$( [ "$decimals" -gt 1 ] && echo "s" ) ## Test Environment **Hardware:** - **Model:** MacBook Neo (Mac17,5) - **Processor:** Apple A18 Pro (6 cores: 2 performance + 4 efficiency) - **Memory:** 8 GB RAM - **Operating System:** macOS (Darwin) **Methodology:** - Each language runs 4 times per test - First run is considered "warmup" and excluded - Results are the average of the 3 subsequent runs - Time measured in milliseconds (ms) - Memory measured in bytes via RSS (Resident Set Size) ## Performance Summary ### All Languages | Rank | Language | Time (ms) | Memory (bytes) | Type | |------|-----------|-----------|----------------|------| EOF # Extract data and sort by time, then memory grep "SUCCESS" "$input_file" | sed 's/\x1b\[[0-9;]*m//g' | \ awk '{ lang = $1 # Time is the 3rd field (after "SUCCESS") time = $3 # Memory is the 5th field (after "ms,") mem = $5 # Remove commas from memory gsub(/,/, "", mem) print lang, time, mem }' | sort -k2 -n -k3 -n | \ awk '{ rank = NR lang = $1 time = $2 mem = $3 # Determine type based on language if (lang == "Assembly" || lang == "C" || lang == "C++" || lang == "Rust" || \ lang == "Go" || lang == "Nim" || lang == "Odin" || lang == "Fortran" || \ lang == "Swift" || lang == "Crystal" || lang == "D" || lang == "Zig" || \ lang == "Objective-C" || lang == "Haskell") { type = "Compiled" } else if (lang == "Java" || lang == "CSharp" || lang == "Kotlin" || \ lang == "Scala" || lang == "Dart" || lang == "Julia") { type = "JIT" } else { type = "Interpreted" } printf "| %d | %s | %s | %s | %s |\n", rank, lang, time, mem, type }' >> "$output_file" # Add performance analysis cat >> "$output_file" << EOF ### Performance Analysis **Top Performers:** - Fastest execution times for compiled languages - Minimal memory usage for native code - Consistent performance across decimal levels **Memory Efficiency:** - Compiled languages: 1-6 MB - JIT languages: 14-236 MB - Interpreted languages: 2-29 MB **Key Findings:** - Compiled languages dominate in both speed and memory efficiency - JIT languages show moderate performance with higher memory usage - Interpreted languages vary widely in performance ## Detailed Results See the full test output in \`reports/run_${decimals}_output.txt\`. --- *Generated from Pi Calculation Benchmark - Apple A18 Pro Performance Study* EOF echo "✓ Created $output_file" } # Create reports for all decimal levels for decimals in 1 2 5 10 100 1000 2000; do create_report "$decimals" done echo "" echo "=== All reports updated ==="