Zomis / Brainduck

Brainfuck Interpreter in Java/Groovy, with a Groovy DSL
40 stars 1 forks source link

Improve running + analyze performance #20

Open Zomis opened 8 years ago

Zomis commented 8 years ago

As more and more features are added to the analysis, it takes longer and longer time to run. The FizzBuzz analysis alone takes about 17 seconds on my reasonably-fast computer. Running without analysing takes 15.6 seconds Running without groovy code enabled takes 0.7 seconds

Possible ways to improve performance:

Zomis commented 8 years ago

By having Groovy parse the script only once, instead of once every time it is runned, full analysis of FizzBuzz now takes 2.3 seconds

Zomis commented 8 years ago

A problem with keeping track of [ and ] is that BrainFCommand.WHILE and BrainFCommand.END_WHILE are referenced a lot in the source. To jump faster one way would be to keep track of the possible destination indexes within the command, but this is just not possible with the enum. Another alternative would be to store the information some other place within the BrainfuckRunner or BrainfuckCode, but I am not sure that is a good option.

Zomis commented 8 years ago

Take a look at https://github.com/rdebath/Brainfuck for a fast interpreter.

Zomis commented 7 years ago

57 should help a lot with this.