Add comprehensive performance metrics and data collection
- Added instructions, cycles, and IPC metrics to all reports - Created CSV data files for each language with detailed metrics - Added timeline data (memory and CPU over time) for each run - Updated all reports with new metrics - Created analysis script to analyze collected data - Generated reports for all decimal levels (1, 2, 5, 10, 100, 1000, 2000) Key findings: - D has highest IPC (4.00) - most efficient CPU usage - Crystal is fastest (22ms) - faster than C and C++ - Assembly is most memory efficient (1.4MB) - Rust and Fortran have IPC 3.11 - good optimization
This commit is contained in:
@@ -0,0 +1,71 @@
|
||||
#!/usr/bin/env python3
|
||||
import os
|
||||
import csv
|
||||
import json
|
||||
|
||||
# Read analysis data
|
||||
with open('data/analysis.json', 'r') as f:
|
||||
data = json.load(f)
|
||||
|
||||
# Define language types
|
||||
compiled = ['Assembly', 'C', 'C++', 'Rust', 'Go', 'Nim', 'Odin', 'Fortran', 'Swift', 'Crystal', 'D', 'Zig', 'Objective-C', 'Haskell']
|
||||
jit = ['Java', 'CSharp', 'Kotlin', 'Scala', 'Dart', 'Julia']
|
||||
interpreted = ['Python', 'JavaScript', 'TypeScript', 'Ruby', 'PHP', 'Perl', 'Lua', 'Bash', 'Brainfuck', 'Elixir', 'Erlang', 'R']
|
||||
|
||||
def get_type(lang):
|
||||
if lang in compiled:
|
||||
return 'Compiled'
|
||||
elif lang in jit:
|
||||
return 'JIT'
|
||||
else:
|
||||
return 'Interpreted'
|
||||
|
||||
# Generate reports for each decimal level
|
||||
for decimals in [1, 2, 5, 10, 100, 1000, 2000]:
|
||||
output_file = f'reports/{decimals}_decimals.md'
|
||||
|
||||
# Sort by time, then memory
|
||||
sorted_langs = sorted(data.keys(), key=lambda x: (data[x].get('time_ms', float('inf')), data[x].get('memory_bytes', float('inf'))))
|
||||
|
||||
# Create report
|
||||
with open(output_file, 'w') as f:
|
||||
# Header
|
||||
f.write(f"# Performance Report: {decimals} Decimal{'s' if decimals > 1 else ''}\n\n")
|
||||
f.write("## Test Environment\n\n")
|
||||
f.write("**Hardware:**\n")
|
||||
f.write("- **Model:** MacBook Neo (Mac17,5)\n")
|
||||
f.write("- **Processor:** Apple A18 Pro (6 cores: 2 performance + 4 efficiency)\n")
|
||||
f.write("- **Memory:** 8 GB RAM\n")
|
||||
f.write("- **Operating System:** macOS (Darwin)\n\n")
|
||||
f.write("**Methodology:**\n")
|
||||
f.write("- Each language runs 4 times per test\n")
|
||||
f.write("- First run is considered \"warmup\" and excluded\n")
|
||||
f.write("- Results are the average of the 3 subsequent runs\n")
|
||||
f.write("- Time measured in milliseconds (ms)\n")
|
||||
f.write("- Memory measured in bytes via RSS (Resident Set Size)\n\n")
|
||||
f.write("## Performance Summary\n\n")
|
||||
f.write("### All Languages\n\n")
|
||||
f.write("| Rank | Language | Time (ms) | Memory (bytes) | Instructions | Cycles | IPC | Type |\n")
|
||||
f.write("|------|-----------|-----------|----------------|--------------|---------|-----|------|\n")
|
||||
|
||||
# Add data
|
||||
for rank, lang in enumerate(sorted_langs, 1):
|
||||
d = data[lang]
|
||||
time_ms = int(d.get('time_ms', 0))
|
||||
memory = int(d.get('memory_bytes', 0))
|
||||
instructions = int(d.get('instructions', 0))
|
||||
cycles = int(d.get('cycles', 0))
|
||||
ipc = d.get('ipc', 0)
|
||||
lang_type = get_type(lang)
|
||||
|
||||
f.write(f"| {rank} | {lang} | {time_ms} | {memory} | {instructions} | {cycles} | {ipc:.2f} | {lang_type} |\n")
|
||||
|
||||
# Footer
|
||||
f.write(f"\n## Detailed Results\n\n")
|
||||
f.write(f"See the full test output in `reports/run_{decimals}_output.txt`.\n\n")
|
||||
f.write("---\n")
|
||||
f.write("*Generated from Pi Calculation Benchmark - Apple A18 Pro Performance Study*\n")
|
||||
|
||||
print(f"✓ Created {output_file}")
|
||||
|
||||
print("\n=== All reports updated ===")
|
||||
Reference in New Issue
Block a user