Burgershot
  • Home
  • Members
  • Team
  • Help
  • Search
  • Register
  • Login
  • Home
  • Members
  • Help
  • Search
Burgershot SA-MP Pawn Scripting [Pawn] Opinion on PVars

Poll: What should I do?
You do not have permission to vote in this poll.
Use normal variables
100.00%
1 100.00%
Use PVars/PP lists
0%
0 0%
Total 1 vote(s) 100%
* You voted for this item. [Show Results]

 
  • 0 Vote(s) - 0 Average
Pawn Opinion on PVars
Pinch
Offline

Burgershot Member
Posts: 391
Threads: 19
Joined: Apr 2019
Reputation: 22
Location: Belgrade, Serbia
#1
2021-06-05, 09:16 AM
Hi everyone, I've gotten bored so I started writing a gamemode for fun, I want it to be a RolePlay gamemode with all of the stuff (like the NG-RP) but I want it to be smooth on bigger player base too..

I ran some tests and those were the results
Code:
Timing "PawnPlus list"...
      Mean = 480.00ns
      Mode = 475.00ns
    Median = 477.00ns
     Range = 5.00ns
Timing "Normal var"...
      Mean = 200.00ns
      Mode = 199.00ns
    Median = 200.00ns
     Range = 3.00ns
Timing "Pvar timings"...
      Mean = 483.00ns
      Mode = 481.00ns
    Median = 483.00ns
     Range = 4.00ns

The code I used:

Code:
new List:pp_list[1000];

enum E_PLAYER_DATA {
    E_PLAYER_SOME_VAR,
    E_PLAYER_SOME_VAR_2,
    E_PLAYER_SOME_VAR_3
};
new PlayerData[1000][E_PLAYER_DATA];

hook OnScriptInit()
{
    for(new i = 0; i < 1000; ++i) {
        pp_list[i] = list_new();
        list_resize_var(pp_list[i], 3, VAR_NULL);    
    }
    return Y_HOOKS_CONTINUE_RETURN_1;
}

public OnPlayerConnect(playerid)
{
    wait_ms(5000);
    print("A");
    RUN_TIMING("PawnPlus list")
    {
        list_set(pp_list[playerid], 0, 10000000);
        list_set(pp_list[playerid], 1, 10000000);
        list_set(pp_list[playerid], 2, 10000000);
    }
    RUN_TIMING("Normal var")
    {
        PlayerData[playerid][E_PLAYER_SOME_VAR] = 10000000;
        PlayerData[playerid][E_PLAYER_SOME_VAR_2] = 10000000;
        PlayerData[playerid][E_PLAYER_SOME_VAR_3] = 10000000;
    }
    RUN_TIMING("Pvar timings")
    {
        SetPVarInt(playerid, "key1", 10000000);
        SetPVarInt(playerid, "key2", 10000000);
        SetPVarInt(playerid, "key3", 10000000);
    }
    return 1;
}

So, is it worth it?
Should I use PVars/PP lists? Does it even matter that much when the diff is 200ns?
Using Pawn.CMD?
If you're doing so, this is the very first sign that you absolutely shouldn't utilize your all powerful P-Code knowledge in any of the scripting discussion topics.
« Next Oldest | Next Newest »



Messages In This Thread
Opinion on PVars - by Pinch - 2021-06-05, 09:16 AM
RE: Opinion on PVars - by IllidanS4 - 2021-06-05, 09:34 AM
RE: Opinion on PVars - by Pinch - 2021-06-05, 09:55 AM
RE: Opinion on PVars - by Y_Less - 2021-06-05, 11:26 AM

  • View a Printable Version
  • Subscribe to this thread
Forum Jump:

© Burgershot - Powered by our Community and MyBB Original Theme by Emerald

Linear Mode
Threaded Mode