[Include] fastCommands 0.4.2b | Fast and Simple Co
#1

fastCommands -Fast and Simple Command Processor

Info: Include fCmd is an improved version of cmd (to Zeex) in more features and faster performance. Include used in the same way as an ordinary cmd.

Ver:0.4.2b


Functions:


pawn Код:
native ARG<slot>; //(string) (slot = argument);
    native ARG_FLOAT<slot>; //(float) (slot = argument);
    native ARG_INT<slot>; //(int) (slot = argument);
    native ARG_COUNT<>;//number of arguments in the command
    native Command_Alt(fromCmd, toCmd);//Dodawanie alternatywnej komendy (np /v to /cars)
Cons:
Код:
argCount[MAX_PLAYERS], 
argData[MAX_PLAYERS][MAX_ARGPARAMETRS][96];
Benefits:
  • Execution speed.
    No need to use sscanf for most commands with parameters.
    Faster write a command with arguments (and they do not need to create local variables).
Example of using command with an argument:


pawn Код:
CMD:sping(playerid, params[])
{
    if(ARG_COUNT<> <= 0)
    {
        SendClientMessage(playerid, 0xFF0000FF, "Użyj /sping <id gracza>");
        return 1;
    }
   
    if(!IsPlayerConnected(ARG_INT<0>))
    {
        SendClientMessage(playerid, 0xFF0000FF, "The given player is not connected");
        return 1;
    }
   
    new str[32];
    format(str, sizeof(str), "Ping player id %d is %dms", ARG_INT<0>, GetPlayerPing(ARG_INT<0>));
    SendClientMessage(playerid, 0x00FF00FF, str);
    return 1;
}
Download: Click Me!


Contrast of speed of operation:
Код:
#1[fastCmd]: 25ms
#2[fastCmd]: 25ms
#3[fastCmd]: 25ms
#4[fastCmd]: 24ms
#5[fastCmd]: 24ms
#6[fastCmd]: 26ms

#1[zcmd]: 357ms
#2[zCmd]: 344ms
#3[zCmd]: 347ms
#4[zCmd]: 346ms
#5[zCmd]: 349ms
#6[zCmd]: 345ms
Код:
 new t;

t = tickcount();
for(new i;i<50000;i++)
{
CallLocalFunction("OnPlayerCommandText", "dd", 0, "/mst");
}
printf("#1[%s]: %dms", type, tickcount() - t);

t = tickcount();
for(new i;i<50000;i++)
{
CallLocalFunction("OnPlayerCommandText", "dd", 0, "/mst fsdfsdf");
}
printf("#2[%s]: %dms", type, tickcount() - t);

t = tickcount();
for(new i;i<50000;i++)
{
CallLocalFunction("OnPlayerCommandText", "dd", 0, "/dsd");
}
printf("#3[%s]: %dms",type, tickcount() - t);

t = tickcount();
for(new i;i<50000;i++)
{
CallLocalFunction("OnPlayerCommandText", "dd", 0, "/gdfgdfgdgdgdg");
}
printf("#4[%s]: %dms",type, tickcount() - t);


t = tickcount();
for(new i;i<50000;i++)
{
CallLocalFunction("OnPlayerCommandText", "dd", 0, "/gdfgdfgdgdgdg sdfgdfgdfg");
}
printf("#5[%s]: %dms",type, tickcount() - t);

t = tickcount();
for(new i;i<50000;i++)
{
CallLocalFunction("OnPlayerCommandText", "dd", 0, "/sping 0");
}
printf("#6[%s]: %dms",type, tickcount() - t);

t = tickcount();
Sorry for my English, the original topic http://pawno.pl/index.php?/topic/252...and-processor/
Reply
#2

it seem good if its really that fast, not sure if only being fast makes it good >.>
However i will still prefer sscanf over this arguments system..
Reply
#3

what's bothering me is we have too many people trying to do their own thing instead of contributing to existing scripts (which is key to community development)
Reply
#4

Quote:
Originally Posted by ******
Посмотреть сообщение
ZCMD is slower than this because it is safe, all you have done is removed all security in the name of speed.
I'd rather have security than worry about speed loss furthermore how to expect anyone to ever run as many commands as the test? It is simply impossible and therefore the difference is/would be too small to notice.
Reply
#5

******, what security is zcmd which no fcmd?
Reply
#6

these examples do not cause any error

Test (2)



The library is on my server for several days (05/04/2014) has so far not caused any crash.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)