SetPVarInt / GetPVarInt vs Normal Vars.
#1

SetPVarInt / GetPVarInt vs Normal Vars.

Who it's better and what i should to use?

And another question. SetPVarInt got automatic clearing after public OnPlayerDisconect or clear on public OnPlayerConnect?

Ex: A system engine it's faster by using SetPVarInt / GetPVarInt or by using normal vars like new EngineStauts[MAX_VEHICLES]; ?
Reply
#2

PVars can be used in any filterscripts and intractable

PVars will delete when OnPlayerDisconnect is called otherwise you can remove it manually

PVars are slower than object variables like 20%?

But I'd rather to use object variable if not going to intract them in another filterscript and yeah new EngineStatus[MAX_VEHICLES] is better.
Reply
#3

Quote:
Originally Posted by 0x88
Посмотреть сообщение
PVars can be used in any filterscripts and intractable

PVars are deleted when OnPlayerDisconnect is called otherwise you can remove it manually

PVars are slower than object variables like 20%?

But I'd rather to use object variable if not going to intract them in another filterscript and yeah new EngineStatus[MAX_VEHICLES] is better.
Ty for answers +rep
Reply
#4

Quote:
Originally Posted by ******
Посмотреть сообщение
Not sure where you got 20% from, my estimate would have been closer to 2000% slower - they are function calls instead of pawn operations (opcodes), a since a single function call takes multiple opcodes, they can't be that close. How far off are they? I did some tests:

https://gist.github.com/Y-Less/7f815...ece8386cfbfe28

Results:

Код:
  ||========================||
  || STARTING PROFILINGS... ||
  ||========================||

Timing "ReadGVars"...
          Mean = 4541.00ns
          Mode = 4556.00ns
        Median = 4556.00ns
         Range = 188.00ns

Timing "ReadGlobals"...
          Mean = 268.00ns
          Mode = 268.00ns
        Median = 268.00ns
         Range = 5.00ns

Timing "ReadLocals"...
          Mean = 285.00ns
          Mode = 284.00ns
        Median = 284.00ns
         Range = 8.00ns

Timing "ReadPVars"...
          Mean = 3918.00ns
          Mode = 3920.00ns
        Median = 3920.00ns
         Range = 26.00ns

Timing "ReadProperties"...
          Mean = 6791.00ns
          Mode = 6788.00ns
        Median = 6788.00ns
         Range = 26.00ns

Timing "ReadSVars"...
          Mean = 3823.00ns
          Mode = 3823.00ns
        Median = 3823.00ns
         Range = 24.00ns

Timing "WriteGVars"...
          Mean = 5755.00ns
          Mode = 5741.00ns
        Median = 5753.00ns
         Range = 40.00ns

Timing "WriteGlobals"...
          Mean = 257.00ns
          Mode = 255.00ns
        Median = 255.00ns
         Range = 21.00ns

Timing "WriteLocals"...
          Mean = 282.00ns
          Mode = 281.00ns
        Median = 281.00ns
         Range = 20.00ns

Timing "WritePVars"...
          Mean = 4122.00ns
          Mode = 4120.00ns
        Median = 4117.00ns
         Range = 57.00ns

Timing "WriteProperties"...
          Mean = 9890.00ns
          Mode = 9836.00ns
        Median = 9850.00ns
         Range = 243.00ns

Timing "WriteSVars"...
          Mean = 4188.00ns
          Mode = 4168.00ns
        Median = 4182.00ns
         Range = 63.00ns

*** Profilings: 12

  ||======================||
  || PROFILINGS COMPLETE! ||
  ||======================||
So only about 1400% slower. They do have important uses, and should be chosen where appropriate, but they should not be the default. Bear in mind, I did each version 30 times to get vaguely measurable results. Also note that these are VERY rough - they show good trends since the differences are so extreme, but they are not perfectly precise. I'd say 10x slower is a good estimate of a lower-bound for the difference, but computers and other effects can alter those numbers up or down a lot.
Wow, ty for this information.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)