We are currently working on new rules for what content should and shouldn't be allowed on this website, and are looking for feedback! See Esolang:2026 topicality proposal to view and give feedback on the current draft.

User:Splot-dev/splotbf/benchmark

From Esolang
Jump to navigation Jump to search

Code for the benchmark for my splotbf brainf interpreter! For https://esolangs.org/wiki/Brainfuck_speed_test.

Make sure you are in the directory that you have dbfi.b in.

Also, please install pexpect and splotbf from pip.

Finally, if you're feeling generous, you can remove 0.2 seconds from the result time, as that is the time that dbfi takes to load up and accept input in my interpreter.

Works only for MacOS and Linux.

from time import perf_counter, sleep
import pexpect # docs https://pexpect.readthedocs.io/

start = perf_counter()
child = pexpect.spawn('bf dbfi.b') # you'll need the dbfi file
sleep(0.2) # you gotta wait for dbfi to start accepting input
child.send('+++++++++++++++++[>+++++++++++++++<-]>[>+++++++++++++++++[>+++++++++++++++<-]<-]>>>++++++++[<++++++>-]<.!')
child.expect('1')
end = perf_counter()

final = end-start # if you're feeling generous.. you can remove 0.2
print(f'\nTime: {final} seconds.')
print(f'Result: {child.read().decode()}')