Currently developing a GameBoy emulator and would love to be able to run at 60 FPS in debug mode, is it feasible?

80 points nicolas-siplis

Hey everyone! First of all, here's the source code for the emulator along with the output of cargo flamegraph

https://preview.redd.it/u0ij33z8sdw91.png?width=10000&format=png&auto=webp&s=670d85dde096a02d534db9ad4e45425c084e5284

https://github.com/nicolas-siplis/feboy

Sorry for the huge image, haven't figured out a way for the graph to show the full name for function calls and this was the only thing I could think of.

If I'm reading the output correctly, it looks like my most of my time is spent in the InterruptHandler::get\_state and InstructionFetcher::fetch\_instruction functions.

I'm super puzzled as to how I could improve the performance of the former because it's actually not that much logic. For the latter I guess it makes sense that it's taking such a significant amount of time since it's basically a gigantic match statement.

I was also surprised as to how much removing HashMap from the InstructionHandler made a difference, since playing in debug mode went from being simply impossible (less than 5FPS would be my guess) to "only" a really miserable experience (at least 10 FPS).