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
C (gcc -O2)
33ms
Pseudocode (JIT)
32ms
Node.js
88ms
LuaJIT
94ms
Pseudocode (VM)
520ms
Python 3.11
680ms
Fibonacci (fib(35), recursive)
C (gcc -O2)
52ms
Pseudocode (JIT)
61ms
LuaJIT
89ms
Node.js
95ms
Pseudocode (VM)
850ms
Python 3.11
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
- The VM interprets bytecode normally
- Loop back-edges increment a heat counter
- When a loop becomes "hot" (executed many times), recording starts
- The trace recorder captures operations along the execution path
- Recorded traces are compiled to native x86-64 code
- 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