Which method is more efficient ? Task vs Each time check
I want to understand how costly using set_task is ? Hence wanted to know the difference.
Why I ask this question is because this hook is going to be called numerous times on using grenade and wanted to know whether the calculation is worth of prevent a set_task. This uses task to enable grenade. Code:
public EventRoundStart()Code:
public EventRoundStart() |
Re: Which method is more efficient ? Task vs Each time check
I would say the second option but it really makes no difference.
But save the time in a global var only. You don't need the bool. Look at antiflood. |
Re: Which method is more efficient ? Task vs Each time check
Typically, if the function that you are trying to perform naturally works in a hook, you should prefer that method.
It really depends on what you are trying to do. In this case, I would probably use the set_task() because it's easier to understand what the code is doing and as far as efficiency goes it's going to be negligibly different. |
Re: Which method is more efficient ? Task vs Each time check
Thank you for checking it and giving your opinion.
@Black Rose I used the bool because I thought why to use a comparison check since the method above will be called numerous times when the player selects grenade and presses fire button (because it wont allow you to throw and the hook is gonna be called again). After the x seconds, that condition will be true for that round, so used a boolean. @fysiks Yes exactly! It totally depends up on what am trying to do. Sorry that I didn't explain that. Why I asked this question is because this hook is going to be called numerous times on using grenade and wanted to know whether the calculation is worth of prevent a set_task. I ll edit the question. I do understand that I might be making the usual mistake: Over optimization. Hence wanted your views. |
| All times are GMT -4. The time now is 18:39. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.