HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Hashtable benchmark of the natives::

12-10-2009, 12:56 AM#1
weaaddar
Expand Zinc:
I was testing the hashtable natives if it was worth using the contains method vs a loadinteger and not storing 0.

The means of testing was trying each method 10 times in an iterative loop of 1000 tries. This was to lower the time wasted on simply setting i= i+1. After each test the stopwatch was destroyed and a sleep was used to clense the pop limit.

Each of these results were multiplied by 1000 to make them large enough to notice a difference. Test + numbers::
  • /* exists miss */HaveSavedInteger(table,0,1); 10.527
  • /* Get Miss */ LoadInteger(table,0,1); 9.892
  • /* set */SaveInteger(table,0,2,2); 10.943
  • /* Get hit */ LoadInteger(table,0,2); 10.248
  • /* exists hit */ HaveSavedInteger(table,0,2); 10.999
  • /* flush */ RemoveSavedInteger(table,0,2); 11.355
Admittedly, the numbers seem a bit different then my try with handles, but it seems when integers are concerned, Remove is slower then setting to 0, and contains is slower then just getting.

I didn't assign to variables or test or anything like that to be fair, as if statements in jass seem to be lightening fast, whereas setting is slower.
12-10-2009, 06:01 AM#2
DioD
what about gamecache and arrays?

can you perform same test with cache and arrays, may be using cache will be faster then hashtable
12-12-2009, 04:40 AM#3
weaaddar
I've performed some benchmarks in the JH thread, but the general thing is that
array < hashtable < gamecache by an order of 1 each. So GC is about 3x slower then array, and ht is about 2x slower then array.

Of course GC tends to be real slower, as you often use I2S and strings are slower.
12-12-2009, 09:33 AM#4
DioD
soo keep structs and struct handle via hash is best way?