brainfuck speed test

From Esolang
Jump to navigation Jump to search

The following is a speed test for many brainfuck interpreters and compilers.

Each interepreter runs dbfi which runs this program:



All programs are compiled/interpreted with the most commonly used optimization, All C/C++ programs are compiled using MinGW.

Caption text
Interpreter Language Author Time (seconds) Compilation argument Execution argument
qdb C Daniel B. Cristofani 0.3158194 gcc qdb.c -o qdb.exe -O2 type program.b|qdb dbfi.b
brainfuck Python interpreter Python User:None1 62.4023704 no compilation type program.b|python dbfi.b
jitbf 1.0.0 Python User:None1 0.2879994 no compilation type program.b|python -c "import jitbf100;jitbf100.bf2jit(open('dbfi.b').read())()"
jitbf 1.0.1 Python User:None1 0.2273109 no compilation type program.b|python -c "import jitbf101;jitbf101.bf2jit(open('dbfi.b').read())()"
bffsree C Sree Kotay 0.0548232 no compilation type program.b|.\bffsree_gcc dbfi.b
brainfuck-rs Rust GitHub user Jomy10 5.6635058 cargo b --release type program.b|.\brainfuck-rs dbfi.b
bfi Python GitHub user eriknyquist 13.8061329 no compilation type program.b | python -c "from bfi import interpret;interpret(open('dbfi.b').read())"
brainfuck C++ interpreter C++ User:None1 0.2374176 gcc brainfuck.cpp -o brainfuck.exe -O2 type program.b | .\brainfuck dbfi.b
sbi C Daniel B. Cristofani 0.257173 gcc sbi.c -o sbi.exe -O2 type program.b | .\brainfuck sbi.b
bf-rs interpreter Rust User:Pro465 0.2337166 rustc -C opt-level=3 type program.b | .\bfrs-i dbfi.b
bf-rs compiler Rust User:Pro465 0.6085359 rustc -C opt-level=3 type program.b | .\bfrs-i dbfi.b
BrainFExec 1.0.0 C# User:None1 0.209492 .\brainfexec100 dbfi.b type program.b | .\dbfi
BrainFExec 1.0.1 C# User:None1 0.154928 .\brainfexec101 dbfi.b -o type program.b | .\dbfi
brainfuck JavaScript interpreter JavaScript User:None1 4.7179623 no compilation node brainfuck.js
esco 0.512 C++ Zasenko Sergey 1.1404712 no compilation type program.b|.\esco -t bf dbfi.b
bfrun 1.2 Java Unknown 0.4624814 no compilation type program.b|java -jar bfrun.jar -O3 dbfi.b

Speed chart

The following is a bar graph showing the time consumption of every brainfuck interpreter:

Brainfuck speed chart


bffsree>jitbf>BrainFExec>bf-rs interpreter>qdb>bfrun>brainfuck C++ interpreter>sbi>bf-rs compiler>esco>brainfuck JavaScript interpreter>brainfuck-rs>bfi>brainfuck Python interpreter

bffsree is obviously the fastest, my jitbf also did this quite quickly, but since dbfi is very short, the optimization in jitbf 1.0.1 does not change the speed much (moreover, in this test, jitbf spends more than half the time to compile LLVM IR than to JIT interpret it), making it just a tiny bit faster than jitbf 1.0.0. brainfuck-rs, the brainfuck interpreter in Rust is also very slow, but bf-rs's compiler is faster, and bf-rs's interpreter is even faster. And finally, brainfuck Python interpreter is no match for the others.

Note: The speed of a brainfuck interpreter is dependent on the computer, and also Windows caches in the second time I run, so the first run might be inaccurate.

Request for other interpreters

If you want me to test more interpreters, you can post it at the talk page just like User:Pro465 did, but remember that your interpreter should run correctly under Windows, or I am good enough at the programming language to modify it to let it run correctly under Windows.