Performance Benchmarks

Comparing Pseudocode's tracing JIT compiler against other languages.

Note: The JIT compiler is optimized for numeric loops. Complex operations like string manipulation or dictionary access run through the bytecode VM.

Loop Performance

These benchmarks measure tight loop performance, where the JIT compiler provides the most benefit.

10 Million Increment Loop

Lower is better
C (gcc -O2)
33ms
33ms
Pseudocode (JIT)
32ms
32ms
Node.js
88ms
88ms
LuaJIT
94ms
94ms
Pseudocode (VM)
520ms
520ms
Python 3.11
680ms
680ms

Fibonacci (fib(35), recursive)

Lower is better
C (gcc -O2)
52ms
52ms
Pseudocode (JIT)
61ms
61ms
LuaJIT
89ms
89ms
Node.js
95ms
95ms
Pseudocode (VM)
850ms
850ms
Python 3.11
1.8s
1.8s

Test Code

The benchmark code used for these tests.

increment_loop.pseudo
let sum = 0
for i in 1..10000001 do
    sum = sum + 1
end
print(sum)
fibonacci.pseudo
fn fib(n)
    if n <= 1 then
        return n
    end
    return fib(n-1) + fib(n-2)
end

print(fib(35))

JIT Architecture

Pseudocode uses a tracing JIT compiler that records hot loop execution paths and compiles them to native x86-64 machine code.

How It Works

  1. The VM interprets bytecode normally
  2. Loop back-edges increment a heat counter
  3. When a loop becomes "hot" (executed many times), recording starts
  4. The trace recorder captures operations along the execution path
  5. Recorded traces are compiled to native x86-64 code
  6. Future loop iterations run the native code directly

Optimizations Applied

  • Register Allocation Yes
  • Constant Folding Yes
  • Dead Code Elimination Yes
  • Function Inlining Yes
  • Loop Unrolling Planned
  • Type Specialization Partial

Test Environment

System Configuration

  • CPU AMD Ryzen 9 5900X
  • RAM 32GB DDR4-3600
  • OS Ubuntu 22.04 LTS
  • GCC Version 11.4.0
  • Python Version 3.11.0
  • Node.js Version 20.10.0
  • LuaJIT Version 2.1.0

Running Benchmarks

You can run the benchmarks yourself:

Terminal
# Clone the repository
git clone https://github.com/NagusameCS/Pseudocode.git
cd Pseudocode

# Build the VM
cd cvm && make

# Run benchmarks (VM mode)
./pseudo ../benchmarks/bench_jit.pseudo

# Run benchmarks (JIT mode)
./pseudo -j ../benchmarks/bench_jit.pseudo