Is it bad to call GetCVar every tick?
Moderator: GZDoom Developers
Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.
Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.
Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
-
-
- Posts: 17481
- Joined: Mon Oct 27, 2003 12:07 am
- Location: Kuala Lumpur, Malaysia
Is it bad to call GetCVar every tick?
I have a unified UI drawer class that draws stuff to the screen tinted/overlayed with custom RGB values that are saved per-user... it calls GetCVar every tick to get the colours. My question is if this is bad programming practice? I can't seem to measure any performance issues but I'm curious if getting a CVar value every tick might be bad or not... I mean, does GetCVar cause hard disk wear and tear from having to read the user's INI?
-
- Lead GZDoom+Raze Developer
- Posts: 49211
- Joined: Sat Jul 19, 2003 10:19 am
- Location: Germany
Re: Is it bad to call GetCVar every tick?
Like with everything it depends on how often you call it each tick. The main issue in this case is that it performs a linear search over the existing CVar's which is not particularly optimal.
Do a few more such searches and it will eventually have an impact on performance.
Do a few more such searches and it will eventually have an impact on performance.
-
- Posts: 38
- Joined: Thu Mar 08, 2018 3:40 am
Re: Is it bad to call GetCVar every tick?
Good to know. We were having a discussion about caching CVar objects over here. I'm doing it in my WAD but apparently this is only safe to do for transient CVars.
-
- Posts: 1606
- Joined: Mon Jun 12, 2017 12:57 am
Re: Is it bad to call GetCVar every tick?
This and sunlust map 24, or any other that have more than 1000 monsters.Nash wrote:I can't seem to measure any performance issues
Unles you have gaming computer, which can fried eggs to you at videocard...mmm refined taste of nvidia chipset...
You do not have the required permissions to view the files attached to this post.