Cokemonkey11
Spell Reviewer
- Joined
- May 9, 2006
- Messages
- 3,575
Hello,
I'm in the process of developing a new system and one of the important things I needed to know was about the performance difference between IsUnitInGroup() and HandleTable.exists().
Before I can begin this though I first need to know how the cost of HandleTable.exists() varies as more handles are added to it.
I've used Vexorian's Table 3.1. My machine's specifications are as follows: Intel i5-2410M @ 2.3GHz, 6GB DDR3-SDRAM, Windows 7 x64.
The first notable test I've conducted compared the cost of HandleTable.exists(u) when the handle table instance contains 10 and 1000 units.
http://i.imgur.com/ZLaBaq8.png
From this graph we can see that for realistic counts of units, the cost of HandleTable.exists() is relatively constant.
We can also infer from the script which derived the data that GetRandomInt() has fairly constant cost in relation to the values of its arguments.
Above: Script used to test FPS for HandleTable.exists() with unit count of 1000.
I'm in the process of developing a new system and one of the important things I needed to know was about the performance difference between IsUnitInGroup() and HandleTable.exists().
Before I can begin this though I first need to know how the cost of HandleTable.exists() varies as more handles are added to it.
I've used Vexorian's Table 3.1. My machine's specifications are as follows: Intel i5-2410M @ 2.3GHz, 6GB DDR3-SDRAM, Windows 7 x64.
The first notable test I've conducted compared the cost of HandleTable.exists(u) when the handle table instance contains 10 and 1000 units.
http://i.imgur.com/ZLaBaq8.png
From this graph we can see that for realistic counts of units, the cost of HandleTable.exists() is relatively constant.
We can also infer from the script which derived the data that GetRandomInt() has fairly constant cost in relation to the values of its arguments.
JASS:
scope thousandTable initializer i
globals
private integer kIPS=0
private HandleTable ht
private unit array list[1000]
private group grp=CreateGroup()
endglobals
private function p takes nothing returns nothing
local integer j=0
local unit u=list[GetRandomInt(0,999)]
loop
exitwhen j>=kIPS
call ht.exists(u)
set j=j+1
endloop
endfunction
private function c takes nothing returns boolean
set kIPS=kIPS+10
call DisplayTimedTextToPlayer(Player(0),0.,0.,3.,I2S(kIPS))
return false
endfunction
private function i takes nothing returns nothing
local trigger t=CreateTrigger()
local integer j=0
set ht=HandleTable.create()
loop
exitwhen j>=1000
set list[j]=CreateUnit(Player(1),'hfoo',0.,0.,0.)
call GroupAddUnit(grp,list[j])
set ht[list[j]]=0
set j=j+1
endloop
call TimerStart(CreateTimer(),1./1000.,true,function p)
call TriggerRegisterPlayerEvent(t,Player(0),EVENT_PLAYER_END_CINEMATIC)
call TriggerAddCondition(t,Condition(function c))
call SetTimeOfDayScale(0.)
set t=null
endfunction
endscope
Above: Script used to test FPS for HandleTable.exists() with unit count of 1000.