14.06.2015, 05:54
(
Последний раз редактировалось DRIFT_HUNTER; 14.06.2015 в 08:11.
)
Just use pawn states...
[EDIT] Nvm, forget about states, here is quick and dirty version to benchmark both processors (zcmd and i-zcmd)
Here are results that i get (Note they are not averaged, its just a single run)
[EDIT] Nvm, forget about states, here is quick and dirty version to benchmark both processors (zcmd and i-zcmd)
pawn Код:
#include <a_samp>
#include <zcmd>
#define TEST1 1000
#define TEST2 10000
#define TEST3 100000
#define COMMANDS_CALLED 5
main()
{
print("ZCMD vs I-ZCMD Benchmark");
TestZCMD(TEST1);
TestIZCMD(TEST1);
TestZCMD(TEST2);
TestIZCMD(TEST2);
TestZCMD(TEST3);
TestIZCMD(TEST3);
}
forward TestZCMD(tests);
public TestZCMD(tests)
{
new time[2]; time[0]=GetTickCount();
for(new i = 0; i < tests; i ++)
{
CallLocalFunction("OnPlayerCommandText", "is", INVALID_PLAYER_ID, "/somecmd");
CallLocalFunction("OnPlayerCommandText", "is", INVALID_PLAYER_ID, "/anothercmd someparam");
CallLocalFunction("OnPlayerCommandText", "is", INVALID_PLAYER_ID, "/verylong command with many params");
CallLocalFunction("OnPlayerCommandText", "is", INVALID_PLAYER_ID, "/invalidcmd");//These command does not exists (we need to handle these to...)
CallLocalFunction("OnPlayerCommandText", "is", INVALID_PLAYER_ID, "/invalidcmd with params");//These command does not exists (we need to handle these to...)
}
time[1]=GetTickCount();
printf("Benchmark of %d ZCMD commands: %d", tests * COMMANDS_CALLED, time[1] - time[0]);
}
#define OnPlayerCommandText OnPlayerCommandText2
forward OnPlayerCommandText2(playerid, cmdtext[]);
#include <izcmd>
forward TestIZCMD(tests);
public TestIZCMD(tests)
{
new time[2]; time[0]=GetTickCount();
for(new i = 0; i < tests; i ++)
{
CallLocalFunction("OnPlayerCommandText2", "is", INVALID_PLAYER_ID, "/somecmd");
CallLocalFunction("OnPlayerCommandText2", "is", INVALID_PLAYER_ID, "/anothercmd someparam");
CallLocalFunction("OnPlayerCommandText2", "is", INVALID_PLAYER_ID, "/verylong command with many params");
CallLocalFunction("OnPlayerCommandText2", "is", INVALID_PLAYER_ID, "/invalidcmd");//These command does not exists (we need to handle these to...)
CallLocalFunction("OnPlayerCommandText2", "is", INVALID_PLAYER_ID, "/invalidcmd with params");//These command does not exists (we need to handle these to...)
}
time[1]=GetTickCount();
printf("Benchmark of %d i-ZCMD commands: %d", tests * COMMANDS_CALLED, time[1] - time[0]);
}
//--->>> Both processors have same syntax for commands and callbacks so we define them only once...
public OnPlayerCommandPerformed(playerid, cmdtext[], success)
{
return 1;
}
public OnPlayerCommandReceived(playerid, cmdtext[])
{
return 1;
}
CMD:somecmd(playerid, params[])
{
return 1;
}
CMD:anothercmd(playerid, params[])
{
return 1;
}
CMD:verylong(playerid, params[])
{
return 1;
}
Код:
[10:08:19] ZCMD vs I-ZCMD Benchmark [10:08:19] Benchmark of 5000 ZCMD commands: 25 [10:08:19] Benchmark of 5000 i-ZCMD commands: 16 [10:08:19] Benchmark of 50000 ZCMD commands: 248 [10:08:19] Benchmark of 50000 i-ZCMD commands: 152 [10:08:22] Benchmark of 500000 ZCMD commands: 2462 [10:08:23] Benchmark of 500000 i-ZCMD commands: 1505