BrainF**k Compiler
More than anything, this is an experiment in code golf. My friend @rhysdh540 and I are sort of "competing" to make the fastest BrainF**k compiler and interpreter.
Mine uses Cranelift to compile directly to machine code, and supports AOT and JIT compilation. There's also a lot of optimizations I'm doing on the BrainF**k code before compilation in order to make it faster.
The code can be found here: https://git.thebrokenscript.net/RedstoneWizard08/BrainFuck
Benchmarks
On my terrible laptop, I've run a few benchmarks:
Hardware
- CPU: Intel Core i7-1165G7 @ 4.7 GHz
- RAM: 16 GB LPDDR4 @ 4267 MT/s
- Kernel: Linux 6.18.2-2-cachyos
// tests/fixtures/basic/Hello.b
Benchmark 1: ./a.out
Time (mean ± σ): 367.8 µs ± 325.6 µs [User: 238.3 µs, System: 441.9 µs]
Range (min … max): 0.0 µs … 1946.9 µs 1018 runs// tests/fixtures/basic/Mandelbrot.b
Benchmark 1: ./a.out
Time (mean ± σ): 936.8 ms ± 28.0 ms [User: 928.4 ms, System: 1.2 ms]
Range (min … max): 893.8 ms … 979.0 ms 10 runs