26.07.2010, 02:45
Quote:
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.) #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). |
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.