How much faster is DCMD than STRCMP?
#1

Hi, I have a little question about DCMD. I want to know how much faster DCMD is(Milliseconds)? Only for such a command:

pawn Код:
if(strcmp(cmdtext, "/jetmax",       true) ==0)  {SpawnVehicle(playerid, 493, "Jetmax");         return 1;}
Or
pawn Код:
dcmd_helloworld(playerid, params[])
{
  #pragma unused params
  SpawnVehicle(playerid, 493, "Jetmax");
  return 1;
}
(SpawnVehicle is a function i made. It just creates a vehicle, and destroyes the other.)



And
pawn Код:
if(strcmp(cmd, "/kick", true) == 0)
{
    new tmp[128];
    tmp = strtok(cmdtext, idx);

    if(strlen(tmp) == 0) return SendClientMessage(playerid, 0xFFFFFFFF, "USAGE: /kick [playerid]");

    Kick(strval(tmp));
    return 1;
}
Or
pawn Код:
dcmd_kick(playerid, params[])
{
  if(!strlen(params))
  {
    SendClientMessage(playerid, 0xFF0000FF, "Use: /kick [playerid]");
    return 1;
  }
  strval(params);
  Kick(strval(params));
  return 1;
}
So i don't want to know that DCMD is faster, but i want to see how much faster in milliseconds
Reply
#2

The speed difference shows up once you start having a lot of commands. Otherwise its not much faster. Thats what I heard...I started using dcmd in 01b so I've never used strcmp longer than a few days before that. Just repeating what I heard.
Reply
#3

Quote:
Originally Posted by DracoBlue
I tested (calling 1000000 times) the implementations above, without print-stuff (this would make lag, which isn't called by the function itself!) and had this results:
63 Seconds for first implementation.
18 Seconds for my implementation.
It's all in the topic . Btw. 1 second is 1000 miliseconds, just for the record.

The(other) distadvantage of putting all command logic into _one_ big function (the OnPlayerCommandText-callback) is the (always!) limited size of heap (used when you define new variables). If you don't put the command logic right into that function, but create a function for each command, it is just an extra function call, and you can put as many commands into OnPlayerCommandText without having this problem. The reason why dcmd works that way.

- Draco
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)