Single Brick or Multiple Pebbles - Which One is Heavier?

Hello everybody,
I would like to ask what would be better for performance?

-> A fully transparent window with screen size (664 x 504), where everything is in one refresh method and it's updating when one thing in it changes or each frame when needed

Spoiler
def something_happens @some_window.refresh(@var1,@var2,@var3,@var4,@var5)end
Code:
class Window_SomeWindow < Window_Base  def initialize    (...) < Please dont tell me it will crash my game, because I know this. Okay Shaz? ( ͡° ͜ʖ ͡°)  end  def refresh(var1 = 8,var2 = 4,var3 = 6,var4 = 1,var5 = 99)    contents.clear    #stuff that refers mainly to these five variables  end  def update    super    refresh if @some_variable # there'll be need to update something each frame for some time  endend
~ OR ~

-> Fully transparent windows with smaller sizes, where in general things are updated separately

Spoiler
def something_happens @some_window.refresh(@var1)end
Code:
def something_else_happens  @some_other_window.refresh(@var2)end
~ 5 of these methods (to @var5)

class Window_SomeWindow < Window_Base def initialize (...) < Please dont tell me it will crash my game, because I know this. Okay Shaz? ( ͡° ͜ʖ ͡°) end def refresh(var1 = 8) contents.clear #stuff that refers mainly to that variable end #no update method - it's updated manually from codes aboveend
Code:
class Window_SomeOtherWindow < Window_Base  def initialize    (...) < Please dont tell me it will crash my game, because I know this. Okay Shaz? ( ͡° ͜ʖ ͡°)  end  def refresh(var2 = 8)    contents.clear    #stuff that refers mainly to that variable  end  def update    super    refresh if @some_variable # there'll be need to update that each frame for some time  endend
~ 5 of these classes for 5 variables (where one of them will be updated each frame when needed)
Reference image:

Spoiler
oFuvZYr.png


For now I have 3 separate windows and I'm planning to add 4th for BOSS HP, which will be refreshed each frame when boss appears.

It's better to make one full-screen window and refresh everything at once when something changes + each frame when boss appears?

Or should I leave these 3 windows (each is refreshed separately when needed - each is refreshed upon certain action) and make another separate one for BOSS HP (which will be refreshed each frame when boss appears?
Basically which one will be better optimized and will cause less FPS drop? I cannot test on my PC, since FPS remains untouched, but I know this can bring problems to the others right? Thank you in advance.

Oh and to be clear - EVERYTHING is happening in one scene - in one script.
Generally speaking you should only refresh something when it needs to be refreshed. Otherwise, you're just wasting time re-drawing the same thing. But if you're looking to test the efficiency of your code, there's lots of ways to do it. One simple way is to do something like this.

Spoiler
def run_test puts "Test 1 is starting" start_time = Time.now 1000.times do # test 1 code here end run_time = Time.now - start_time puts "Test 1 is finished. Run time: #{run_time}" puts "Test 2 is starting" start_time = Time.now 1000.times do # test 2 code here end run_time = Time.now - start_time puts "Test 2 is finished. Run time: #{run_time}"end 
That should give you two run times with millisecond accuracy. You can also change '1000' to whatever number you want depending on the complexity of the task. 
Like I said - certain windows are refreshed only when needed. (no updating when not needed)

But, there's one window that is refreshed each frame - why? The boss can be hit that fast, that it will update his HP each frame, so ~

I'm wondering if that would be a problem if full-screen window would be refreshed each frame by something like this:

(...) def boss_is_hit # and that happens even twice each frame! (two players hitting simultaneously) @boss_hp -= 1 @fullscreen_window.refresh(@player1_hp,@player2_hp,@player1_score, @player2_score,@player1_weapontype,@player2_weapontype,@player1_weaponlevel, @player2_weaponlevel,@player1_lives,@player2_lives,@difficulty,@stage,@progress,@boss_hp) end(...)class Window_Fullscreenwindow < Window_Base def initialize super(-12, -12, 664, 504) self.opacity = 0 refresh end def refresh(player1_hp = 10,player2_hp = 10,player1_score = 0, player2_score = 0,player1_weapontype = 0,player2_weapontype = 0, player1_weaponlevel = 1,player2_weaponlevel = 1,player1_lives = 3, player2_lives = 3,difficulty = 0,stage = 1,progress = 0,boss_hp = 0) self.contents.clear #THE WALL OF TEXT HERE TO DRAW ALL THAT STUFFend # Window_Fullscreenwindow < Window_BaseNow I have separate windows for all stuff and I'll leave it be for now.

That boss window is refreshed by this:

def boss_is_hit # and that happens even twice each frame! (two players hitting simultaneously) @boss_hp -= 1 @notfullscreenbuteventiny_window.refresh(@stage,@boss_hp) endBut another question comes to my mind-

I will need another window to generally make events - text, pictures on full screen etc. between stages.

So this will require full-screen window that will be transparent and completely empty (most of the time) - will this reduce performance?

Or... Can I easily draw_text and pictures using bitmap or something like this? + There'll be need to update this each frame for some time.

How I should go about this?
Having each section as different windows would work most efficient I believe. I'm not sure, but you might even be able to use Bitmap.clear_rect() instead of Bitmap.clear (contents.clear) and just clear / recreate a certain from the window instead of recreating the whole window in the case that you only need to update a small section from it. But since it looks like most of your stuff deals with images that might not work too good since you might end up trimming an image.

If anything the boss window should be created separately since you said it'll be refreshing multiple times a frame. But I still don't think you should refresh it every frame, you can just put a check if the bosses hp is different, and if it is then refresh it. If it really is getting hit every frame then it will still be getting refreshed every frame, but every once in awhile you might miss or just not atk which will ease the performance if it's not refreshing.
Yup I had rect's on mind, but I guess there would be lots of work with it + not sure how it'll be handled.

Hmmm... So yeah, I'll leave it for now - I didn't noticed any performance drop, so it's okay for now I think.

About updating the boss window - it's not updated each frame - it is refreshed by this method:

def boss_is_hit # and that happens even twice each frame! (two players hitting simultaneously) @boss_hp -= 1 @notfullscreenbuteventiny_window.refresh(@stage,@boss_hp) endSo, when boss is hit - then it subtracts his HP by 1 and refreshes the window. When you're not hitting him, the window is not updated, saving the performance.

And now - I need a method to draw text / images on screen,

let me find some reference... *searching* ... *seriously?* ... Oh finally ~

Spoiler
246145-the-raiden-project-playstation-screenshot-stage-1-clear.jpg
Something like this appearing on screen + doing some events ~ showing text images, let's say cutscenes.

So... if I'll make a fullsceen fully transparent window with no content in it --- something appears only when stage was cleared - will that be stupid?

Or some other way?

And this 'event' window (thingie/bitmap or whatever) also will be updated when necessary... let's say - giving points to players (giving by 10pts each frame, you know what I mean)...

How to do that I know - having some fun until getting what I want - but first I need to know the basics.

Any suggestions?

What will be the best solution and the 'easiest' one - since there'll be lots of stuff and keep on mind, that different events may even take ~1000 lines of code, so it'd be great if these thingies wouldn't be complicated to handle.

I really appreciate any help.

WtvmtpT.png


OR best solution - dispose window when not needed - re-appear when needed.

I tried putting

@some_window.dispose - but that was giving me crashes related to updating I think.
Yeah for the text I would go with a full screen transparent window. Just hide it when it's not being used, and if for some reason it's updating while it shouldn't be, you could add a "return unless self.visible" in the windows update (I don't remember if it's self.visible but you get the idea).

This window shouldn't effect performance since it sounds like a very simple window that doesn't need any updates unless the text is animated. Also considering the time this window pops up your other hud windows shouldn't be updating since nothing is happening ( I think ) so you shouldn't have any performance problems when this window is shown. And this window should effect performance while it's not shown since it shouldn't be updating.

You might be able to dispose it when you don't need it and recreate it when you need to. But I prefer to just create it once then just use .hide and .show. I don't know which would be better, but the show / hide seems easier to work with.
Yeah I was thinking about showing/hiding, but I wasn't sure if hidden window will be still let's say shown in background - take memory that is.

But yeah, if that would do the thing then that would be even more than best solution, due to its simplicity.

Absolutely none of the windows have update method - everything is updated only by commands.

for example:

def picked_up_bonus case idktype when 0 # health @health = 10 @stats_window.refresh(@health,@lives,@score,@etc) when 1 # life up @lives += 1 @stats_window.refresh(@health,@lives,@score,@etc) endend#etc. etc.So that way, I'm updating the window when needed.

That fullscreen one will be not refreshed during game, only after showing and needing it to work.

So... yeah if hiding window will let's say 'dispose' the window to make it not take memory, then I'll be fine.

Thanks for your time.
This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

BTW, Rikifive, you don't have to ask for every thread to be closed.  Usually just marking it solved is enough.  Closing is only really necessary if it's likely to get necroposted by a newb or something.

Original thread: https://forums.rpgmakerweb.com/threads/single-brick-or-multiple-pebbles-which-one-is-heavier.45836/