Jump to content


Photo

TUVAZ as 0 . Performance impact ?


  • Please log in to reply
9 replies to this topic

#1 tabc3dd

tabc3dd

    GMC Member

  • GMC Member
  • 658 posts

Posted 21 June 2012 - 05:30 PM

Now before everyone starts, I know TUVAZ (treat uninitialized variables as 0) is a terrible option to turn on, causing weird issues and bad programming habit. However, I was wondering if turning it on could improve the speed at which the game runs. Here's my logic :
My game being an RTS, in the midst of a battle tons of instances are created every seconds. With TUVAZ off, everytime these objects are created, 6 variables are initialized, 4 of them being 0s. With TUVAZ on, only 2 variables are initialized, the 4 others being rarely initialized (situational variables). Therefore, wouldn't that mean that with this option on the computer would have much less initialization to do overall, and therefore wouldn't the game run faster ?

Clearly I am mistaken somewhere, but I don't have the required knowledge of GML to understand what happens behind, so I'd be glad if someone could enlighten me. Thanks for your time ^^.

Tabc3dd
  • 0

#2 smash ball

smash ball

    Volcanic Light

  • GMC Member
  • 1117 posts
  • Version:GM7

Posted 21 June 2012 - 05:47 PM

I don't see how initialization will make the game run faster or slower. Collision checks, loops, etc. can make the game run slower, but I don't think initialization will have a noticeable effect on the game. Since you aren't asking about whether or not uninitialized setting is good, I don't see why I have to further explain my standpoint.
  • 1

#3 ShubhamBansod

ShubhamBansod

    Pokemon Master

  • GMC Member
  • 255 posts
  • Version:GM8

Posted 21 June 2012 - 06:30 PM

Now before everyone starts, I know TUVAZ (treat uninitialized variables as 0) is a terrible option to turn on, causing weird issues and bad programming habit. However, I was wondering if turning it on could improve the speed at which the game runs. Here's my logic :
My game being an RTS, in the midst of a battle tons of instances are created every seconds. With TUVAZ off, everytime these objects are created, 6 variables are initialized, 4 of them being 0s. With TUVAZ on, only 2 variables are initialized, the 4 others being rarely initialized (situational variables). Therefore, wouldn't that mean that with this option on the computer would have much less initialization to do overall, and therefore wouldn't the game run faster ?

Clearly I am mistaken somewhere, but I don't have the required knowledge of GML to understand what happens behind, so I'd be glad if someone could enlighten me. Thanks for your time ^^.

Tabc3dd

i stop useing this option from yesterday...i also think that it will set my programming speed fast,but when i gave my game's executable to my friend this make a huge error in game levels .. so i stored using this..and reprogramming my game...:'(
  • 0

#4 tabc3dd

tabc3dd

    GMC Member

  • GMC Member
  • 658 posts

Posted 21 June 2012 - 08:00 PM

I don't see how initialization will make the game run faster or slower. Collision checks, loops, etc. can make the game run slower, but I don't think initialization will have a noticeable effect on the game. Since you aren't asking about whether or not uninitialized setting is good, I don't see why I have to further explain my standpoint.


Well when you have, say a 1000 instances being created every second, that's 4000 times "variable = 0" being executed. Surely that causes some lag no ?
  • 0

#5 smash ball

smash ball

    Volcanic Light

  • GMC Member
  • 1117 posts
  • Version:GM7

Posted 21 June 2012 - 08:23 PM

I highly doubt all 1000 of those instances must be created, but that won't lag the game. Drawing everything and executing serious code will cause the game to slowdown.
  • 0

#6 Big J

Big J

    GMC Member

  • GMC Member
  • 2818 posts
  • Version:GM8.1

Posted 21 June 2012 - 08:44 PM

TUVAZ decreases the performance of the programmer, and increases errors in the game. I would say it has absolutely no impact on the actual performance of the game. Do not check that box, ever. variable_global_exists(), and variable_local_exists() might not be very good practice either, but the fact that they always return true when TUVAZ is enabled shows how terrible TUVAZ really is. This is why your game can run this code and detect the setting of the checkbox:
if (variable_global_exists(""))
{
    show_error("Uninitialized variables are treated as zero! "
    + "Uncheck the box for it in Global Game Settings --> Errors. "
    + "This is worse than division by zero.", true);
}
It checks for a variable that cannot possibly exist, with an empty string as the name. If TUVAZ is on, the function will basically say "Yes, this variable exists" by returning true. At that point your game is screwed anyway, so it shows a fatal error and aborts the execution of the game.
  • 1

#7 smash ball

smash ball

    Volcanic Light

  • GMC Member
  • 1117 posts
  • Version:GM7

Posted 21 June 2012 - 09:05 PM

and increases errors in the game.

That would be incorrect to say. Only the programmer increases errors depending on whether or not the box is checked (and what the programmer's preference is). If the box is checked and you're testing if a variable exists, there's something wrong with you.

Edited by smash ball, 21 June 2012 - 09:06 PM.

  • 0

#8 tabc3dd

tabc3dd

    GMC Member

  • GMC Member
  • 658 posts

Posted 22 June 2012 - 07:56 AM

I highly doubt all 1000 of those instances must be created, but that won't lag the game. Drawing everything and executing serious code will cause the game to slowdown.


Unfortunately they must, that's a 25 vs 25 ship scenario, each firing 20 rounds per second average :/ ... But you're probably right about the lag :)

I've read all your comments, thanks for the opinions, I'll turn it off ^^
  • 0

#9 Yumegiwa

Yumegiwa

    GMC Member

  • GMC Member
  • 33 posts
  • Version:GM8

Posted 22 June 2012 - 08:07 AM

It has no noticeable performance impact no matter what you are doing, and it is not recommended you use it unless you want to assume a default value of 0 for every variable you use unless otherwise specified. If you can keep that mind-frame and make sure to ALWAYS INITIALIZE STRING VARIABLES, you will be fine.

It's not that the check box is evil, it's that most of the people who use it are kids who don't know how to organize a program so that they won't end up with strange errors that they don't understand.
  • 1

#10 Big J

Big J

    GMC Member

  • GMC Member
  • 2818 posts
  • Version:GM8.1

Posted 22 June 2012 - 08:10 AM

I suppose that's true, but if you're doing everything right, you won't need it at all.
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users