[Include] GVars - Just like PVars, except global.
#10

Quote:
Originally Posted by Remis
Посмотреть сообщение
Better not to believe people guesswork without facts. Why don't you just test it yourself?

I was testing its speed and the system seems to be slow.
It loops through the whole array and compares the string with all the strings in the array. It is especially slow if the needed gvar is near the end of the gvar array. Using a binary tree may help for faster search.

Using setproperty & getproperty is more efficient, not only because it is native. Its algorithm is much better.
Even though, if you want to get a nonstring (money for example), you have to unpack it and convert it to a value first, it still faster.


Here are the results (I also edited the .inc defines):

Код:
Setting + Getting + saving in a variable.

10000 Iterations:
Property: 0230
GVar: 20264


100 Iterations:
Property: 0000
GVar: 0019

Setting only (property method needs unpacking and strval() everytime. So the property method is even faster here)


10000 Iterations:
Property: 0219
GVar: 20256


100 Iterations:
Property: 0000
GVar: 0019


Property indexing by names instead of unique values:

Setting + Getting + saving in a variable

I also tested Icognitosґ GVar and it is even faster than the property functions! Use the plugin.


10000 Iterations:
Property: 2113
GVar: 20139


100 Iterations:
Property: 0000
GVar: 0019

The testing script part:
http://pastebin.com/i8cy8JWF
(credits to ******. Used his testing script.)
Why not just use:

#define SetGVar(%1, %2) setproperty(0, "", makehash(%1), %2)
or
#define SetGVar(%1, %2) setproperty(0, %1, 0, %2)
for example

makehash(adler32 / bernstein /.. but it has to return a value, not a string(MD5)) converts a string into an unique ID value (int).
Get/setproperty is far slower than the GVar plugin made by Incognito. Since you provided no code behind your apparently forged numbers, here is real proof in the pudding with code to back it up: http://forum.sa-mp.com/showpost.php?...1&postcount=34

Back then it was me whom Incog was proving wrong. The beauty of GVars (and get/set property) is you have the ability to do loopless lookups of certain array data.
Reply


Messages In This Thread
GVars - Just like PVars, except global. - by Carlton - 25.07.2010, 06:45
Re: GVars - Just like PVars, except global. - by Grim_ - 25.07.2010, 06:49
Re: GVars - Just like PVars, except global. - by [L3th4l] - 25.07.2010, 07:10
Re: GVars - Just like PVars, except global. - by Romanius - 25.07.2010, 07:14
Re: GVars - Just like PVars, except global. - by ViruZZzZ_ChiLLL - 25.07.2010, 07:19
Re: GVars - Just like PVars, except global. - by Grim_ - 25.07.2010, 07:41
Re: GVars - Just like PVars, except global. - by Carlton - 25.07.2010, 15:36
Re: GVars - Just like PVars, except global. - by Remis - 25.07.2010, 15:52
Re: GVars - Just like PVars, except global. - by Carlton - 25.07.2010, 16:16
Re: GVars - Just like PVars, except global. - by nemesis- - 26.07.2010, 02:45

Forum Jump:


Users browsing this thread: 1 Guest(s)