⚡ Neutron Benchmark Suite v2.0

Performance benchmarks comparing Neutron and Python implementations with modern TUI output and output validation.

85.7%
Neutron Win Rate
7
Total Benchmarks
155x
Fastest Speedup

Overview

The benchmark suite runs identical algorithms in both Neutron and Python, comparing their execution times with a beautiful, color-coded interface. Output validation ensures both languages produce identical results.

Benchmarks Included (7 total)

🧮 Algorithms (4 benchmarks)

  • Fibonacci - Iterative Fibonacci calculation (fibonacci(35))
  • Prime Numbers - Generate primes up to 1000
  • Matrix Operations - Multiply two 20x20 matrices
  • Sorting Algorithms - Bubble sort on 15-element array

➗ Math Operations (1 benchmark)

  • Mathematical Functions - Power, square root, GCD calculations

📝 String Operations (1 benchmark)

  • String Manipulation - String reversal, character counting, concatenation

🔄 Loop Performance (1 benchmark)

  • Loop Operations - Various loop types and iterations

Performance Results

╔════════════════════════════════╗
║  Neutron Benchmark Suite v2.0 ║
╚════════════════════════════════╝

Neutron: ./neutron
Python:  Python 3.13.7

Benchmarking: Algorithms
  Fibonacci                 Python: 8.059s     Neutron: 0.052s     Neutron 155.03x faster
  Prime Numbers             Python: 0.112s     Neutron: 0.061s     Neutron 1.84x faster
  Matrix Operations         Python: 0.223s     Neutron: 0.048s     Neutron 4.62x faster
  Sorting Algorithms        Python: 0.175s     Neutron: 0.053s     Neutron 3.26x faster

Benchmarking: Math Operations
  Mathematical Functions    Python: 0.107s     Neutron: 0.026s     Neutron 4.05x faster

Benchmarking: String Operations
  String Manipulation       Python: 0.121s     Neutron: 0.066s     Neutron 1.82x faster

Benchmarking: Loop Performance
  Loop Operations           Python: 0.147s     Neutron: 0.175s     Python 1.18x faster

════ BENCHMARK SUMMARY ═══
Total Benchmarks: 7
Neutron Faster:   6
Python Faster:    1

Neutron Win Rate: 85.7%

🎉 All benchmarks completed successfully! 🎉

Performance Characteristics

💪 Neutron Strengths (85.7% win rate)

  • Recursive/Iterative algorithms (e.g., Fibonacci) - significantly faster due to optimized call stack
  • Numeric computations (e.g., Matrix operations, Prime numbers, Sorting) - 2-5x faster
  • Math operations (e.g., Power, GCD, Square root) - 4x faster
  • String operations - Now faster than Python with proper optimizations
  • Low startup overhead - faster initialization than Python

🐍 Python Strengths

  • Complex nested loops - Slightly faster due to mature CPython optimizations

Output Validation

All benchmarks include output validation to ensure correctness:

  • Both languages must produce identical output
  • Mismatches are highlighted in red with detailed diff
  • Prevents false performance wins from incorrect implementations
  • Example outputs show actual computation results

Running Benchmarks

./run_benchmark.sh

Output Format

The benchmark runner provides:

  • 🎨 Color-coded results (Green = Neutron faster, Yellow = Python faster, Red = Failed/Mismatch)
  • 📊 Organized categories (Algorithms, Math, Strings, Loops)
  • Speed comparisons (e.g., "Neutron 155.03x faster")
  • Output validation - Ensures both languages produce identical results
  • 📈 Summary statistics (Win rate, total benchmarks, success rate)
  • ⏱️ Precise timing (millisecond accuracy)
  • 🔍 Mismatch detection - Shows differences if outputs don't match

Requirements

Neutron

Built binary in project root or build/ directory

Python

Python 3.7+ with bc utility for calculations

System

Linux, macOS, or MSYS2 on Windows

Notes

  • Benchmarks suppress output to avoid I/O overhead affecting results
  • Times are measured using high-precision shell timing
  • Results may vary based on system load and hardware
  • Python JIT warmup not accounted for (cold starts)
  • Both languages run in single-threaded mode