Raised This Month: $51 Target: $400
 12% 

How costly is GetConVar*?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Aderic
Senior Member
Join Date: Oct 2011
Old 02-27-2014 , 18:51   How costly is GetConVar*?
Reply With Quote #1

I have seen it done both ways.
A person declares a convar.... declares a float, hooks the convar change to set the float.

I'm looking at damage multipliers in a damage hook, now this callback may get called often, but is there any actual performance difference if I choose this route vs GetConVarFloat every time the callback is fired?

Thanks,

Mark.
__________________
Aderic is offline
hamilton5
Veteran Member
Join Date: Oct 2012
Location: USA
Old 02-27-2014 , 19:22   Re: How costly is GetConVar*?
Reply With Quote #2

I asked this same thing and was told it's minimal
hamilton5 is offline
VoiDeD
AlliedModders Donor
Join Date: Mar 2009
Location: Illinois, USA
Old 02-27-2014 , 19:51   Re: How costly is GetConVar*?
Reply With Quote #3

In the grand scheme of things, the performance cost is negligible. However, you will probably want to consider how you're using it.

If you're calling it per-frame, chances are you're likely doing more expensive operations in that hook and you'd want to profile your code before you make a decision to turn your GetConVar* into a global variable.

In short: write beautiful maintainable code first, profile and trim the low hanging fruit second.
__________________
VoiDeD is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 06:12.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode