View Single Post
Timiditas
Senior Member
Join Date: Apr 2009
Old 07-29-2010 , 18:09   Re: weapon string to index
Reply With Quote #7

Yes, propably. I have to allocate the weapons to integers to calculate points as well as adress client arrays (accuracy stats for each weapon). A lookup is done each clients death, each time a bullet is fired and each time a bullet hits a player.
Sure, this isn't quite your average OnGameFrame-clog, but meh...

I need it for n1g-css-stats/Dignatio. That plugin needs a clean sweep badly.

I was not just convinced of the tries, so I ran a final test, considering all 26 weapon strings.
This is the result of the 26 weapons, averaged:
Find: 0,000834769
Trie: 0,000167346
Hash: 0,000164885

The older string compare is totally out of the game. My hash/checksum whatever you want to call it is faster than the tries on the first half, but slower on the second half, while the tries seem to stay at the same speed over the whole weaponlist.

It propably won't make any difference wether to choose tries or hashing, speedwise; at least in this special case because its all limited to 26 slots at any time.
So I've chosen to use the hash function and move the most common weapons to the first half of the array.
As well because I can work with the *return* of get_weapon_hash directly, compared to GetTrieValue.

More detailed results and the used code to benchmark is in attachment.
The zip has the results as XLS, saved with Excel 2002/Office XP.
Now go and blame me for not using Open Office.
Attached Thumbnails
Click image for larger version

Name:	benchmark.png
Views:	260
Size:	14.6 KB
ID:	70851  
Attached Files
File Type: zip benchmark.zip (3.7 KB, 89 views)
File Type: sp Get Plugin or Get Source (stringtest.sp - 438 views - 6.0 KB)
__________________


Last edited by Timiditas; 07-30-2010 at 08:10.
Timiditas is offline