Battle hp and mp bars cause fps drop

During battle I was getting 25~40 fps so I decided to investigate what was causing it. After a little bit I found out it's the hp and mp bars that cause it. Disabling them raised my fps to 55~57


With a little more snooping around, I found out it's the update_rate function the culprit. Seems like simply calculating IF the bar should update is enough to cause the fps drop


This is update_rate:


def update_rate
rate = [(@rate - real_rate).abs, setting[:ani_rate]].min
@rate += @rate > real_rate ? -rate : rate
refresh if rate > 0
end


But replacing it with


def update_rate
refresh
end


Is enough to raise the fps from 30 to 50


Same thing with the HP and MP numbers. After changing all of this I now get 58 or 59 fps constantly in battle. The only downside is that the bar width doesn't slide down anymore
It seems odd to me that simple math and logical comparisons would cause the engine to chug that much more than actually refreshing the graphics every time the math/logic runs, though I suppose it's possible if you're using an ancient or crammed-to-the-gills computer or the refresh itself does a super-quick eval on whether to actually process the re-draw.  I haven't looked at the script in question so I couldn't say for sure.


I've had a lot of success in Ace with Vlue's very lightweight Enemy HP Bars script; I use it in the same project as Luna Engine (above all of the Luna Engine scripts).  Not that this is meant to solve your problem, and it's great that you brought this possible inefficiency in the scripts to Archeia's attention - but if you need HP Bars and can't afford the slowdown you're seeing, this could be a good stopgap for you.
I don't get any FPS drops so I don't know how to help with that one exactly :x
It seems odd to me that simple math and logical comparisons would cause the engine to chug that much more than actually refreshing the graphics every time the math/logic runs, though I suppose it's possible if you're using an ancient or crammed-to-the-gills computer or the refresh itself does a super-quick eval on whether to actually process the re-draw.  I haven't looked at the script in question so I couldn't say for sure.



My PC is pretty decent (4gb ram, 1ghz processor, good gpu)

I've had a lot of success in Ace with Vlue's very lightweight Enemy HP Bars script; I use it in the same project as Luna Engine (above all of the Luna Engine scripts).  Not that this is meant to solve your problem, and it's great that you brought this possible inefficiency in the scripts to Archeia's attention - but if you need HP Bars and can't afford the slowdown you're seeing, this could be a good stopgap for you.



The problem here is with the player's status info, i'm not using any enemy bars

I don't get any FPS drops so I don't know how to help with that one exactly :x



Might be some weird interaction with some other script then. But hey it's running really well now so it's all fine
The problem here is with the player's status info, i'm not using any enemy bars

My bad for the misunderstanding; I thought you were talking about enemy bars for some reason.  But with this understood, I can say that I do use the Luna Engine's actor HUD bars (picture mode, even), have similar computer specs to you, and have not seen any lag whatsoever in my game's battles - in fact, the battle system is the only thing in my game that's constantly running at a smooth 59-60 FPS.

Original thread: https://forums.rpgmakerweb.com/threads/battle-hp-and-mp-bars-cause-fps-drop.58794/