Which is quicker?
#1

Using arrays or using SetPVarInt/GetPVarInt etc to store player data?
Reply
#2

Using arrays.

You may have a look at this topic: https://sampforum.blast.hk/showthread.php?tid=268499
Reply
#3

Has anybody done speed tests to see the difference? Are PVars much slower than variables or is there not much of a difference?
Reply
#4

I did a speedtest a while ago. PVars are actually slower than normal variables.
Reply
#5

Quote:
Originally Posted by RyDeR`
Посмотреть сообщение
I did a speedtest a while ago. PVars are actually slower than normal variables.
Quite a lot slower or not much?
Reply
#6

Quite a lot. Here's speedtest if you're still not sure:
Код:
» 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.
pawn Код:
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;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)