13.07.2011, 07:54
Using arrays or using SetPVarInt/GetPVarInt etc to store player data?
» pVars: 1000000 times in 6232 ms. » Normal Array: 1000000 times in 1906 ms. » pVars: 1000000 times in 6233 ms. » Normal Array: 1000000 times in 1907 ms. » pVars: 1000000 times in 6233 ms. » Normal Array: 1000000 times in 1908 ms.
new
g_PlayerVar[MAX_PLAYERS][2]
;
if(!strcmp(cmdtext, "/speedtest", true))
{
new
str[64],
startTick,
i
;
for(i = 0, startTick = GetTickCount(); i < 10000000; ++i)
{
SetPVarInt(playerid, "pv_PlayerVar1", GetPVarInt(playerid, "pv_PlayerVar1") + i);
SetPVarInt(playerid, "pv_PlayerVar2", GetPVarInt(playerid, "pv_PlayerVar2") + i);
}
format(str, sizeof(str), "» pVars: 1000000 times in %d ms.", GetTickCount() - startTick);
SendClientMessage(playerid, -1, str);
for(i = 0, startTick = GetTickCount(); i < 10000000; ++i)
{
g_PlayerVar[playerid][0] += i;
g_PlayerVar[playerid][1] += i;
}
format(str, sizeof(str), "» Normal Array: 1000000 times in %d ms.", GetTickCount() - startTick);
SendClientMessage(playerid, -1, str);
return 1;
}