Which is quicker?
#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


Messages In This Thread
Which is quicker? - by BeckzyBoi - 13.07.2011, 07:54
Re: Which is quicker? - by RyDeR` - 13.07.2011, 08:01
Re: Which is quicker? - by BeckzyBoi - 13.07.2011, 08:31
Re: Which is quicker? - by RyDeR` - 13.07.2011, 08:48
Re: Which is quicker? - by BeckzyBoi - 13.07.2011, 09:18
Re: Which is quicker? - by RyDeR` - 13.07.2011, 10:02

Forum Jump:


Users browsing this thread: 2 Guest(s)