Profiler result's -Optimization mode
#1

I want to optimize my gamemode and I need some help.I'm put profiler plugin on my server from 01:00 to 11:23 today,so i'm get results.

So there are picture who don't want to download:
https://i.imgur.com/dYcv4Fd.png

So if you can tell me what i need to opimize,because i'm not sure what i need to look on this profiler results.For example i don't understand this:

Quote:

operator>=(Float:,Float 1515576 6.83%
operator>(Float:,Float 1281151 3.33%

Is this much?
Quote:

floatcmp 13220491 3.75%

I use floatcmp just in one line in my mode.For afk check

Short code:

Code:
function AFKCheck(playerid)
{
	GetPlayerPos(playerid, PlayerCurrentPos[playerid][0], PlayerCurrentPos[playerid][1], PlayerCurrentPos[playerid][2]);
	if(!floatcmp(PlayerCurrentPos[playerid][0], PlayerLastPos[playerid][LastX]) && !floatcmp(PlayerCurrentPos[playerid][1], PlayerLastPos[playerid][LastY]))
	{
		PovecajPVarInt(playerid, "PlayerAFK", 1);
	}
	else
	{
		SetPVarInt(playerid, "PlayerAFK", 0);
   		AFK[playerid] = false;
	}
	PlayerLastPos[playerid][LastX] = PlayerCurrentPos[playerid][0];
	PlayerLastPos[playerid][LastY] = PlayerCurrentPos[playerid][1];
	PlayerLastPos[playerid][LastZ] = PlayerCurrentPos[playerid][2];

	if(GetPVarInt(playerid, "PlayerAFK") >= 20)
	{
          //kick(afk 20 minute)
        }
       return 1;
}
Quote:

GetSpeed 790181 8.17%

This function I use in OnPlayerUpdate( if(GetSpeed > 299) kick

Code:
GetSpeed(playerid)
{
    new Float:ST[4];
    if(IsPlayerInAnyVehicle(playerid))
    GetVehicleVelocity(GetPlayerVehicleID(playerid),ST[0],ST[1],ST[2]);
    else GetPlayerVelocity(playerid,ST[0],ST[1],ST[2]);
    ST[3] = floatsqroot(floatpower(floatabs(ST[0]), 2.0) + floatpower(floatabs(ST[1]), 2.0) + floatpower(floatabs(ST[2]), 2.0)) * 178.8617875;
    return floatround(ST[3]);
}
I'm upload full .html file in attachmens.Thank you
Reply
#2

First I need to say that my English is not very good,so i hope you will understand me.

1. I had some problems when i had 250+ players(for example my IC Chat is became global chat and also it was start lagg little) ->This is RP server so..I don't use Global Chat) So i'm sure that i need some optimization.Also I need to say that i don't have often a large number of players,so i don't have chance now to turn on profiler with 250+ players(I had it on celebration two years of server so there was many visitors and friends which are not our active players.)

This profiler is turn on midnight(In my time) so we don't have many players at that time .I will post tonight results also.

2.Maybe you are not see,but i'm post full .html file in attachment's.


3.I will look on OnPlayerUpdate,i have GetSpeed check,AntiChaet for Weapons and some check which I can transfer on second timer,it will be better,i think.

FC_OnPlayerUpdate is from include "fuckcleo.inc"
https://pastebin.com/AVrySvAH

So I'm not sure about it.

Thank you very much on answer!
Reply
#3

I can get why you want to kick cheaters fast, but using OnPlayerUpdate is overkill.
This callback is called at least 30 times per second FOR EVERY PLAYER.
If you have 250 players online, you're executing OnPlayerUpdate 7500 times or more every second.

It won't hurt your server when you just transfer all that code to a 1-second timer.
Then that code runs 250 times per second, which is more than enough.

Optimization starts with clearing OnPlayerUpdate.
I never used that callback and I never will, because I can see no reason for any code that needs to run 30 times per second.

If someone cheats with a speed hack, kicking him within 30ms or 1 second won't make any difference, the cheater will be kicked before he can do more damage anyways.
He won't do that much extra damage in 1 second.
Reply
#4

Quote:
Originally Posted by AmigaBlizzard
View Post
I can get why you want to kick cheaters fast, but using OnPlayerUpdate is overkill.
This callback is called at least 30 times per second FOR EVERY PLAYER.
If you have 250 players online, you're executing OnPlayerUpdate 7500 times or more every second.

It won't hurt your server when you just transfer all that code to a 1-second timer.
Then that code runs 250 times per second, which is more than enough.
Using OnPlayerUpdate as a timer is not an overkill but, a very big mistake.
I've kept my anti cheat timer to call every 1.5~2 seconds.

So for say, my timer will call 2 times in 3 seconds instead of 3. It may not make a very big difference, so why put unnecessary load?

Quote:
Originally Posted by AmigaBlizzard
View Post
Optimization starts with clearing OnPlayerUpdate.
I never used that callback and I never will, because I can see no reason for any code that needs to run 30 times per second.
The only reason why anyone will use it is when they're making an Anti AFK system, since OnPlayerUpdate is not called when they are paused.

---

@OP: You can also use GetServerTickRate when you've lots of players in the daytime and let us know of the result.

PHP Code:
CMD:tickrate(playerid)
{
    new 
str[25];
    
format(strsizeof str"Server tickrate: %d."GetServerTickRate());
    
SendClientMessage(playeridCOLOR_GREYstr);
    return 
1;

Reply
#5

Hi guys,

I need help with optimization one my function which is very bad.This function need to count number of seconds of started event.(It shows for all players in game how much is passed seconds from the starting event)

When I start event:
Code:
        EventCount = GetTickCount();
	UpdateEvent();
	eventtimer = SetTimer("UpdateEvent",990,true);
Code:
forward UpdateEvent();
public UpdateEvent()
{
	new rTime[3];
	new string[10];
  	new TimeStamp,TotalEventTime;
  	TimeStamp = GetTickCount();
  	TotalEventTime = TimeStamp - EventCount;
  	ConvertTime(var, TotalRaceTime, rTime[0], rTime[1], rTime[2]);
  	format(string, sizeof string, "%02d:%02d",rTime[0], rTime[1]);
  	TextDrawSetString(TDEvent, string);
}
ConvertTime(used in UpdateEvent)
Code:
#define ConvertTime(%0,%1,%2,%3,%4) \
	new \
	    Float: %0 = floatdiv(%1, 60000) \
	;\
	%2 = floatround(%0, floatround_tozero); \
	%3 = floatround(floatmul(%0 - %2, 60), floatround_tozero); \
	%4 = floatround(floatmul(floatmul(%0 - %2, 60) - %3, 1000), floatround_tozero)
Profiler result for this function:

This is 4. worst function in my mode,so I want to optimize this.Maybe someone have better idea for counting number of seconds?Thanks
Reply
#6

Ohh.
This is one-second timer,so If I convert number of calls into hours i will get: 1175 hours .
1175 hours to days = 48 days(but my mode is started only 2 days with profiler)
It's not possible. So I have mistake in mode(I have stoptimer,but maybe some time it doesn't stop.) I will test it.

2)
Quote:

except stop using arrays for normal variables, but that's a general rule everywhere

You think that I should use:
Code:
new rTime1,rTime2,rTime3 ;
instead
Code:
new rTime[3];
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)