Optimization
#1

First of all guys sorry for spam this thread but my pawn is slow so i wanted to optimize it. All i wanted to ask will this
Код:
if(PlayerInfo[playerid][pAdmin] >= 1 && sscanf(params, "us[86]", targetid, reason))
Do same thing as
Код:
if(PlayerInfo[playerid][pAdmin] >= 1)
{
     if(sscanf(params, "us[86]", targetid, reason))
     {
       rest of code
     }
     return 1;
}
Are things going to stay same? And is the first one faster?
Reply
#2

Both are same just the second one is more beautiful, You don't need to optimaze it like this, here's how we optimaze our codes

PHP код:
example:
public 
OnPlayerText(playerid,text[]) {
   new 
string[500];
   
format(string,sizeof stringtext);
   
SendClientMessageToAll(string);

the string[500]; 500 cells were too unless! you just need 129 [ samp maximum characters per message

PHP код:
public OnPlayerText(playerid,text[]) {
   new 
string[129];
   
format(string,sizeof stringtext);
   
SendClientMessageToAll(string);

Reply
#3

So no difference in speed?? (not even in nanoseconds??)
Reply
#4

Quote:
Originally Posted by Micko123
Посмотреть сообщение
So no difference in speed?? (not even in nanoseconds??)
Nope, no different o.o
Reply
#5

Is there any way that i can make it faster?? My compiler is so slow. I've allready put all buildings in filterscript 'cus i don't want copiler to handle it, but it is still the same
Reply
#6

Nope. Everything fixed. It was problem when i updated YSI. i just restored it and .amx file is 430 KB while before it was 4MB
Reply
#7

Quote:
Originally Posted by Micko123
Посмотреть сообщение
Is there any way that i can make it faster?? My compiler is so slow. I've allready put all buildings in filterscript 'cus i don't want copiler to handle it, but it is still the same
Probably you got something like that new string[999999999999999999999999999999999999999];
Reply
#8

Red post. It was YSI problem
Reply
#9

Didnt mean to double post
Reply
#10

No this wouldn't change compiling speeds as it reads threw the entire code no matter what at the same speed if it's all in one line or not. I recommend to you, you keep it the same. The only way to optimize something is if you're making it more optimal of use by doing this you're not directly effecting anything. My suggestion is you take a look in your script where you use useless amounts of cells, and you look threw the script to make sure that it's storing data the quickest, and most efficient way, you can also start by looking through your gamemode and see if you have any spots where you randomly get the cells when you don't need to as it can effect the performance of your host.

Example of what I mean with the uselessly getting cells


Inefficient way;
pawn Код:
CMD:pm(playerid, params[])
{
    new targetid, text[128], string[164];;
    if(sscanf(params, "us[128]", targetid, text)) { SendClientMessage(playerid, COLOR_DRED, "USAGE: /pm <Player ID> <Text>"); }
    else {
        format(string, sizeof(string), "(( PM to %s{F0F000}: %s ))", PlayerNameEx(targetid), text);
        SendClientMessage(playerid, COLOR_DARKYELLOW, string);
 
        format(string, sizeof(string), "(( PM from %s{F0F000}: %s ))", PlayerNameEx(playerid), text);
        SendClientMessage(targetid, COLOR_DARKYELLOW, string);
    }
    return 1;
}
Efficient way;

pawn Код:
CMD:pm(playerid, params[])
{
    new targetid, text[128];
    if(sscanf(params, "us[128]", targetid, text)) { SendClientMessage(playerid, COLOR_DRED, "USAGE: /pm <Player ID> <Text>"); }
    else {
        new string[164];
        format(string, sizeof(string), "(( PM to %s{F0F000}: %s ))", PlayerNameEx(targetid), text);
        SendClientMessage(playerid, COLOR_DARKYELLOW, string);
 
        format(string, sizeof(string), "(( PM from %s{F0F000}: %s ))", PlayerNameEx(playerid), text);
        SendClientMessage(targetid, COLOR_DARKYELLOW, string);
    }
    return 1;
}
This may seem like a very little change, but it has a noticable impact throughout the gamemode if you do this often for every command. If you're only looking for quicker compilation I'd take out un-used/needed code, or systems that are obsolete or not needed. Other then that you're not really going to get a difference.

The way you're thinking is that just because you shorten the lines of code you use you're going to get faster compilation times but that's incorrect. Let me give you an example in another language (c#)

You expect this;
Код:
using System;
namespace CSharp    {
    class CSharp    {
        static void Main(string[] args) {
            Console.WriteLine("C Sharp woooo!");  }
    }
}
To be quicker then this;
Код:
using System;
namespace CSharp
{
    class CSharp    
    {
        static void Main(string[] args)
    {
            Console.WriteLine(""C Sharp woooo!")  }
    }
}
But in reality it isnt, it just looks a lot cleaner the first. (Imo) so don't expect quicker compilation times unless you remove code.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)