Page 1 of 1

Speed up code (check_say)

Posted: Thu Aug 11, 2005 2:56 am
by juKay
I think you could save alot of CPU cycles if the function check_say were splitted into one function for each thing. Right now you have 12 if that it goes thru ever time someone says something and that is bad in my opinion.

example

Code: Select all

public plugin_init() {
  register_clcmd("say /changerace","change_race_say")
  register_clcmd("team_say /changerace", "change_race_say")
}

public change_race_say (id) {
  change_race(id, 1);
}
I could do it for you if you think this is a good idea and provide you with a .diff

Posted: Thu Aug 11, 2005 7:52 am
by ferret
Oh, I know how to do it. It simply hasn't been at the top of my priority list. This bit of code is some of the oldest in the plugin.

On the same note though, you won't truly save MUCH performance by splitting it up. AMXX will just register x more commands which all have to be checked against as a match. But AMXX will do it slightly faster that way and you'll probably see it next release.

Posted: Thu Aug 11, 2005 8:14 am
by juKay
ferret wrote:Oh, I know how to do it. It simply hasn't been at the top of my priority list. This bit of code is some of the oldest in the plugin.

On the same note though, you won't truly save MUCH performance by splitting it up. AMXX will just register x more commands which all have to be checked against as a match. But AMXX will do it slightly faster that way and you'll probably see it next release.
Yes I know and that was my point with it, better to move it down the chain. I also know that you can do it, just simply wanted to help so you get some time over for other things.

Posted: Thu Aug 11, 2005 10:55 am
by Geesu
12 if statements is not a lot of CPU cycles....

Posted: Thu Aug 11, 2005 11:36 am
by juKay
Geesu wrote:12 if statements is not a lot of CPU cycles....
Checked a log and it had 159 say/team_say in it for a 20 minutes time span. That make a totalt of 1908 checks that is not needed. Even if they would be needed they could be executed at a lower level than checking them in a plugin.

Or am I wrong when I assume that register a command like say /command would be faster than doing a check with if/else statements?

Posted: Tue Sep 13, 2005 8:30 am
by Lazarus Long
done - it will be part of 2.6.2