Open becomingplural opened 1 month ago
Hi @becomingplural (love the profile pic) thanks for raising this, I'm on vacation at the moment but will be looking into this when I get back!
Oh wait are you the creator of Platformer Plus?? I've been meaning to find out how to reach out to you about potentially merging it (and Adventure Plus) with the GB Studio core for a future release and work out ways we could extend the application to better integrate it. If you're interested that is
Yup, that's me! Happy to chat sometime, probably the easiest way is to find me in the discord (@hauntology)
Hi @becomingplural I spent some time looking into this and following those steps I also saw that version 4 had slightly higher CPU usage. Comparing the code generated by 3.2.1 and 4.0.0 there were a few inefficiencies especially around the code generated for if statements, where it was needlessly storing/reading values to temporary variables. I've managed to fix up the code generation and it's now performing similar to 3.2.1 for me, and in some cases slightly faster.
Debug builds are available here if you'd like to try it out before the next release: https://github.com/chrismaltby/gb-studio/actions/runs/9996147033
Got a few things I want to work on first but I'll be in touch on Discord about the other things when I'm ready to discuss more :-)
Attached scripts (ie. Attach Script to Button) are using significantly more CPU when the same project is recreated or ported from 3.2. I am using the Emulicious emulator to profile CPU usage, and the increase seems to roughly double the impact of an attached script. The issue has been noted by a number of folks who are using the Platformer+ plugin with the Attach Script to State event, however, the issue appears to be broader.
Steps to reproduce the behavior:
In GBStudio 3.2, create a new project.
In the scene's On Init, add Attach Script to Button.
Add a Loop While to the script. This is for debug purposes so that the impact will be visible continuously.
Within the loop, add some logic. Ie. an If-statement that checks a value and writes another.
Add a Wait 1 Frame event so that the loop does not freeze.
Compile the project to a rom and store it for comparison.
Open the project in GBStudio 4.0 (or recreate the project in 4.0)
Compile to a .rom and store it for comparison.
Load each .rom in Emulicious and compare the CPU graphs
Expected behavior The CPU graph in the 4.0 version should be several % higher than the 3.2 version.
Platform (please complete the following information):
Additional context I'm not sure if this counts as a bug, but when comparing CPU usage, it seems that 4.0 always uses a little more than 3.2. Roughly 2% of the DMG cpu and 1% of the GBColor. I mention that finding here because I've taken it into consideration in comparing the script usage.