What is more efficient?
Im trying to optimize my plugin but Im not sure whats more efficient:
I need to get values from cvars but I have to do it very often (player spawn and ongameframe). So whats better: 1. getting cvar values from cvars in OnPluginStart and saving them in global variables so I can just use the global variables and hook the convar changes so when they get changed I modify the global variables. or 2. no global variables for cvars, but using getconvarint, getconvarfloat, getconvarstring and getconvarbool every time I need to access the cvar variables. |
Re: What is more efficient?
Well this is what GetConVarInt does: https://github.com/alliedmodders/sou....cpp#L335-L348
From that i would guess it will be slightly better to cache it in global variables, especially if you need it every frame. |
Re: What is more efficient?
Quote:
|
Re: What is more efficient?
It's meaningless to "cache" non-string ConVars. As far as I know, SM does this cache for you in the background.
|
Re: What is more efficient?
Quote:
|
Re: What is more efficient?
Quote:
|
Re: What is more efficient?
I cache all my cvars and hook changes to update the cache.
|
Re: What is more efficient?
AFAIK, Sourcemod caches cvars on its own; other than to save calls to GetConVarString, caching cvars is unnecessary.
My Friendly Mode plugin once cached all its cvars in such a manner. It was hell to maintain, and ultimately unnecessary as I later found out. Further, the new syntax seems to discourage caching in this manner, with the cool .IntValue .FloatValue and .BoolValue properties. |
Re: What is more efficient?
Quote:
|
All times are GMT -4. The time now is 18:28. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.